Skip to content

fix: clarify missing or empty data_collection_permissions.required - #6246

Open
Thanatos9404 wants to merge 1 commit into
mozilla:masterfrom
Thanatos9404:data-collection-required-message
Open

Thanatos9404 wants to merge 1 commit into
mozilla:masterfrom
Thanatos9404:data-collection-required-message

Conversation

@Thanatos9404

Copy link
Copy Markdown

Fixes #6118

An extension that doesn't collect any data, or only declares optional data collection permissions, has to set "required": ["none"] (now documented, mozilla/extension-workshop#2402). When required was left out or empty, the linter reported generic schema errors that don't say so:

data_collection_permissions Before After
{"optional": ["technicalAndInteraction"]} MANIFEST_FIELD_REQUIRED: "/browser_specific_settings/gecko/data_collection_permissions" must have required property 'required', description "See https://mzl.la/1ZOhoEN (MDN Docs) for more information." MISSING_REQUIRED_DATA_COLLECTION_PERMISSIONS
{"required": [], "optional": ["technicalAndInteraction"]} JSON_INVALID: "/browser_specific_settings/gecko/data_collection_permissions/required" must NOT have fewer than 1 items, description "Your JSON file could not be parsed." MISSING_REQUIRED_DATA_COLLECTION_PERMISSIONS

As suggested in the issue, this adds a message next to the existing data collection ones:

The "required" list of data collection permissions is missing or empty.

The "/browser_specific_settings/gecko/data_collection_permissions/required" property must list at least one data collection permission. If the extension doesn't collect any data, or only collects data with optional data collection permissions, set "required" to ["none"]. More information at: https://mzl.la/firefox-builtin-data-consent

errorLookup() maps the two schema errors behind this (required with missingProperty: 'required' on the data_collection_permissions object, and minItems on its required list) to the new message, under browser_specific_settings and the MV2 applications key. It is still an error and the manifest is still invalid; only the text changes. The issue mentions a warning, but src/schema/updates/manifest.json makes required mandatory with at least one item, so a warning would change what AMO accepts rather than how it explains it.

The rule is added to docs/rules.md, and docs/index.html is regenerated with scripts/build-rules.

Tests

The two existing tests that asserted the generic messages now expect the new one. I added the two cases from the issue (only optional set, with required missing or empty), one for applications, and one checking that a required value that isn't a list is still reported as MANIFEST_FIELD_INVALID. The five new-message cases fail on master.

Run locally on Linux with Node 22: npm run build, npm run test-once (64 suites, 1,737 tests passed), npm run test-integration-linter, npm run lint (no errors; the 3 existing jest/expect-expect warnings in test.manifestjson.js are unrelated), and Prettier on the changed files. I also ran bin/addons-linter on the two manifests above, before and after the change.

An extension that doesn't collect any data, or only declares optional
data collection permissions, has to set "required" to ["none"]. Leaving
"required" out, or setting it to [], was reported with the generic
schema errors (MANIFEST_FIELD_REQUIRED, or JSON_INVALID with "Your JSON
file could not be parsed."), which don't say what to do.

Map both schema errors to a new MISSING_REQUIRED_DATA_COLLECTION_PERMISSIONS
error that points to ["none"] and the data consent documentation. It is
still an error, and the manifest is still invalid.

Fixes mozilla#6118
@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.69%. Comparing base (171d7fd) to head (5cb58c0).
⚠️ Report is 9 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6246   +/-   ##
=======================================
  Coverage   98.68%   98.69%           
=======================================
  Files          49       49           
  Lines        2963     2978   +15     
  Branches      918      923    +5     
=======================================
+ Hits         2924     2939   +15     
  Misses         39       39           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Manifest validation requires data_collection_permissions.required even when an extension only declares optional data collection permissions

1 participant