addons-linter icon indicating copy to clipboard operation
addons-linter copied to clipboard

DATA_COLLECTION_PERMISSIONS_PROP_RESERVED

Open regseb opened this issue 1 month ago • 5 comments

When you add the data_collection_permissions property in manifest.json, addons-linter reports the error: The "data_collection_permissions" property is reserved. (DATA_COLLECTION_PERMISSIONS_PROP_RESERVED)

But when you publish an extension without the data_collection_permissions property, you get the warning:

The "data_collection_permissions" property is missing.

Avertissement: The "/browser_specific_settings/gecko/data_collection_permissions" property is required for all new Firefox extensions, and will be required for new versions of existing extensions in the future. Please add this key to the manifest. More information at: https://mzl.la/firefox-builtin-data-consent

regseb avatar Nov 08 '25 15:11 regseb

Are you using a recent version of the linter? Support was enabled by default in 8.3.0 : https://github.com/mozilla/addons-linter/releases/tag/8.3.0

The current latest version is 8.4.0

Rob--W avatar Nov 09 '25 05:11 Rob--W

  • The CLI reports a warning if the data_collection_permissions property is missing;
  • The API reports an error because the data_collection_permissions property is reserved.

I get the error because I use the Metalint linter aggregator, which uses the addons-linter API.


  • package.json

    {
      "name": "testcase",
      "version": "1.0.0",
      "type": "module",
      "dependencies": {
        "addons-linter": "8.4.0"
      }
    }
    
  • linter.js

    import linter from "addons-linter";
    
    await linter.createInstance({
        config: {
            _: [process.argv[2]],
            logLevel: "debug",
        },
    }).run();
    
  • with/manifest.json

    {
      "browser_specific_settings": {
        "gecko": {
          "id": "[email protected]",
          "data_collection_permissions": { "required": ["none"] }
        }
      },
      "manifest_version": 3,
      "name": "testcase",
      "version": "1.0.0"
    }
    
  • without/manifest.json

    {
      "browser_specific_settings": {
        "gecko": {
          "id": "[email protected]"
        }
      },
      "manifest_version": 3,
      "name": "testcase",
      "version": "1.0.0"
    }
    

  1. npm install

  2. npx addons-linter ./with/

    errors          0
    warnings        0
    
  3. npx addons-linter ./without/

    errors          0
    warnings        1 (MISSING_DATA_COLLECTION_PERMISSIONS)
    
    
  4. node linter.js ./with/

    errors          1 (DATA_COLLECTION_PERMISSIONS_PROP_RESERVED)
    warnings        0
    
  5. node linter.js ./without/

    errors          0
    warnings        0
    

regseb avatar Nov 09 '25 09:11 regseb

I am guessing that's because you're passing your own config, which overrides the entire config object in the linter. In most cases, this is fine, except for features that are gated by a config flag. You could add enableDataCollectionPermissions: true as follows:

import linter from "addons-linter";

await linter.createInstance({
    config: {
        _: [process.argv[2]],
        logLevel: "debug",
        enableDataCollectionPermissions: true,
    },
}).run();

willdurand avatar Nov 10 '25 09:11 willdurand

I need to pass the configuration to set the directory (with the _ property).

I think the same default values should be used when using the CLI and the API.

  • const.js

    + const DEFAULT_CONFIG = {
    +   // ...
    +   enableDataCollectionPermissions: true,
    + };
    
  • yargs-options.js

    + import { DEFAULT_CONFIG } from "./const.js";
    
        'enable-data-collection-permissions': {
          describe: 'Enable data collection permissions support',
          type: 'boolean',
    -     default: true,
    +     default: DEFAULT_CONFIG.enableDataCollectionPermissions,
        },
    
  • main.js

    + import { DEFAULT_CONFIG } from "./const.js";
    
      export function createInstance({
        config = getConfig({ useCLI: isRunFromCLI() }).argv,
        runAsBinary = false,
      } = {}) {
        log.level = config.logLevel;
        log.info('Creating new linter instance', { config });
        // eslint-disable-next-line no-param-reassign
        config.runAsBinary = runAsBinary;
    -   return new Linter(config);
    +   return new Linter({ ...DEFAULT_CONFIG, ...config });
      }
    

regseb avatar Nov 10 '25 09:11 regseb

We triaged this issue during out triage meeting today and we agreed that applying changes to the linter to make sure the default config is applied by default (and additional option passed through the CLI or programmatically while using addons-linter as a library) would override the default.

This change would also be beneficial for third parties using add-ons linter as a library but also for the mozilla/web-ext project, where we would not need additional changes besides updating the addons-linter dependencies to have new addons-linter default behaviors enabled as expected.

rpl avatar Nov 20 '25 13:11 rpl