Skip to content

Conversation

caugner
Copy link
Contributor

@caugner caugner commented Aug 27, 2025

Summary

  1. Validates the built data.json against the schemas.
  2. Removes the maxProperties requirement for the browsers object from the browsers schema.

Test results and supporting details

This revealed two minor issues:

  1. The browsers schema was requiring a maximum of one browser defined in browsers. This requirement only applies to the individual browser/*.json files, not the built data.json, so this requirement was removed.
  2. The __meta object in the built data.json is not currently covered by the schema, so we cannot validate it.

Related issues

Fixes #27564.

@github-actions github-actions bot added schema Isses or pull requests regarding the JSON schema files used in this project. infra Infrastructure issues (npm, GitHub Actions, releases) of this project linter Issues or pull requests regarding the tests / linter of the JSON files. scripts Issues or pull requests regarding the scripts in scripts/. labels Aug 27, 2025
@caugner caugner changed the title enhance(build): validate data against schemas enhance(build): validate built data.json against schemas Aug 27, 2025
@caugner caugner requested review from Elchi3 and queengooborg August 27, 2025 09:23
@github-actions github-actions bot added the size:m [PR only] 25-100 LoC changed label Aug 27, 2025
Copy link
Contributor

github-actions bot commented Aug 27, 2025

Tip: Review these changes grouped by change (recommended for most PRs), or grouped by feature (for large PRs).

const writeData = async () => {
const dest = new URL('data.json', targetdir);
const data = await createDataBundle();
validate(data);
Copy link
Contributor Author

@caugner caugner Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

If validation fails, the validation errors are logged via console.error, but we don't bail out, to avoid disruption for contributors in the unlikely event that this ever happens on main. In either case, these errors won't get unnoticed, because they will appear on every npm install (via the prepare script).

@ddbeck
Copy link
Contributor

ddbeck commented Aug 28, 2025

  • The __meta object in the built data.json is not currently covered by the schema, so we cannot validate it.

FWIW, I raised this as a concern in #17574 and got shot down on doing anything about it.

@caugner
Copy link
Contributor Author

caugner commented Aug 28, 2025

FWIW, I raised this as a concern in #17574 and got shot down on doing anything about it.

FWIW, here's the meta schema (isolated, like the other two):

{
  "$schema": "http://json-schema.org/schema",

  "definitions": {
    "meta_block": {
      "type": "object",
      "properties": {
        "timestamp": {
          "type": "string",
          "format": "date-time"
        },
        "version": {
          "type": "string"
        }
      },
      "required": ["timestamp", "version"],
      "additionalProperties": false
    }
  },

  "properties": {
    "__meta": {
      "$ref": "#/definitions/meta_block"
    }
  },

  "title": "MetaData",
  "type": "object",
  "required": ["__meta"],
  "additionalProperties": false,
  "maxProperties": 1,
  "minProperties": 1
}

Unfortunately, ajv gives me an error when validating the data:

TYPE must be string

  2 |   "__meta": {
  3 |     "version": "7.1.0",
> 4 |     "timestamp": "2025-08-28T14:30:46.924Z"
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^ 👈🏽  type must be string
  5 |   }
  6 | }

That error doesn't make sense, but given this is not a priority, I would declare the scope of this PR to validate the built data against the existing schemas.

@caugner caugner requested a review from a team as a code owner September 16, 2025 13:38
@caugner caugner requested review from queengooborg and removed request for Elchi3 September 16, 2025 13:43
@caugner caugner force-pushed the 27564-validate-data-against-schema branch from b884975 to c046688 Compare October 7, 2025 12:32
@github-actions github-actions bot added data:api Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API size:l [PR only] 101-1000 LoC changed and removed size:m [PR only] 25-100 LoC changed labels Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data:api Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API infra Infrastructure issues (npm, GitHub Actions, releases) of this project linter Issues or pull requests regarding the tests / linter of the JSON files. schema Isses or pull requests regarding the JSON schema files used in this project. scripts Issues or pull requests regarding the scripts in scripts/. size:l [PR only] 101-1000 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The built package is not validated against the schema

5 participants