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

this.parsedJSON.content_scripts.forEach is not a function

Open Rob--W opened this issue 2 years ago β€’ 0 comments

Describe the problem and steps to reproduce it:

While looking into #4645, I noticed that the underlying issue is that one cannot make any assumptions on this.parsedJSON, other than it being JSON. There are multiple instances where this assumption is violated: https://github.com/mozilla/addons-linter/blob/e1f890216c9e8edcf51ff68bab3e57d658111fc7/src/parsers/manifestjson.js#L533-L537 https://github.com/mozilla/addons-linter/blob/e1f890216c9e8edcf51ff68bab3e57d658111fc7/src/parsers/manifestjson.js#L884-L888

Test case, create manifest.json with the following content and run the linter on it:

{
  "content_scripts": {
    "length": true
  }
}

Similarly,

{
  "browser_action": {
    "theme_icons": true
  }
}

What happened?

TypeError: this.parsedJSON.content_scripts.forEach is not a function
TypeError: this.parsedJSON.browser_action.theme_icons.forEach is not a function

What did you expect to happen?

Validation errors for the manifest being invalid, including MANIFEST_FIELD_INVALID with message "/content_scripts" must be an array. And for the second test case, "/browser_action/theme_icons" must be an array

┆Issue is synchronized with this Jira Task

Rob--W avatar Jan 06 '23 17:01 Rob--W