Skip to content

Guard against future web feature schema changes #510

Open

Description

@jcscottiii

Background

From @past on this PR

Can you guard against future schema changes via assertions or similar? It's better to not display any information if the schema has changed than to silently ingest unexpected data.

The data could lead to use returning things like this from the features API:

...
    {
      "feature_id": "features",
      "name": ""
    },
    {
      "feature_id": "groups",
      "name": ""
    },
    {
      "feature_id": "snapshots",
      "name": ""
    }
...

Definition of done

  • Add a validate helper that is called inside the Parse method for the web feature data.json
    func (p Parser) Parse(in io.ReadCloser) (map[string]web_platform_dx__web_features.FeatureData, error) {
    defer in.Close()
    var ret map[string]web_platform_dx__web_features.FeatureData
    decoder := json.NewDecoder(in)
    err := decoder.Decode(&ret)
    if err != nil {
    return nil, errors.Join(ErrUnexpectedFormat, err)
    }
    return ret, nil
    }
    • That validate method should do some additional checks to make sure the data is as expected. If not, return a new error.
      • At a minimum, it should check that the names for each feature is not empty.

Activity

  1. jcscottiii commented on Oct 6, 2024

    @jcscottiii
    CollaboratorAuthor

    We can simplify this logic now. After talking to Daniel (@ddbeck) from the Web DX repository, we can leverage the semantic version. We should:

    1. Store the major version that we support in the code.
    2. Parse the version string from the GitHub release.
    3. If it fits, we can assume it is safe. If it does not, we should return an error then and stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions