aklinker1 / publish-browser-extension

CI tool to easily publish browser extensions
MIT License
49 stars 5 forks source link

Error when working with Firefox Addons API #23

Open modos189 opened 5 months ago

modos189 commented 5 months ago

When trying to submit my extension to Firefox Addons I get an error

Reqeust: https://addons.mozilla.org/api/v5/addons/addon/%7Biitc-button-beta%7D
Response: {
  "_data": {
    "detail": "Not found."
  }
}
 ERROR  [GET] "https://addons.mozilla.org/api/v5/addons/addon/%7Biitc-button-beta%7D": 404 Not Found                                                                                                                                                                                                  12:18:03 PM

  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async $fetch2 (node_modules/ofetch/dist/shared/ofetch.897a6909.cjs:274:15)
  at async FirefoxAddonStore.submit (node_modules/publish-browser-extension/dist/cli.cjs:3309:19)
  at async Task.task [as taskFn] (node_modules/publish-browser-extension/dist/cli.cjs:3488:11)
  at async Task.run (node_modules/listr2/dist/index.cjs:2143:11)

The wrappedExtensionId method is required to wrap the extension ID in quotes and as stated in the project code, it is required by the API. But I removed these lines:

    if (id.includes("@"))
      return id;
    if (!id.startsWith("{"))
      id = "{" + id;
    if (!id.endsWith("}"))
      id += "}";

And now the sending of the extension is successful (at least running with the DRY_RUN key)

UP: I had an error in the extension (the version number did not meet the length requirements) and got this error:

› [firefox] Submitting new version
Request: https://addons.mozilla.org/api/v5/addons/addon/iitc-button-beta/versions/
Response: {
  "_data": {
    "upload": [
      "Upload is not valid."
    ]
Error:  [POST] "https://addons.mozilla.org/api/v5/addons/addon/iitc-button-beta/versions/": 400 Bad Request

When trying to submit using web-ext sign I got a more elaborate error log indicating that the error was in the version number. Is it possible for publish-browser-extension to show a detailed error log?

aklinker1 commented 5 months ago

iitc-button-beta is not your ID. You should use the UUID from the extension's dashboard, under "Edit Product Page" > "Technical Details".

aklinker1 commented 5 months ago

Is it possible for publish-browser-extension to show a detailed error log?

Hmm, I thought I print out a URL that you can open in the browser to see the validation errors. But maybe this error is being throw before that?

https://github.com/aklinker1/publish-browser-extension/blob/726cf57e9abfd58e8c206b3363819c9a2bb51ccc/src/firefox/firefox-addon-store.ts#L68

the version number did not meet the length requirements

What version did you try and use? Like 1.0? web-ext does a lint step before the upload, this doesn't do that, instead relying on the API to tell you if something is wrong. But I guess in this case, something fails?

modos189 commented 5 months ago

iitc-button-beta is not your ID. You should use the UUID from the extension's dashboard, under "Edit Product Page" > "Technical Details".

Yeah, you're right. Interestingly, after the changes I described, the extension is successfully unloaded not by UUID, but by extension name from the URL. Should it be possible to allow both options?

modos189 commented 5 months ago

What version did you try and use? Like 1.0?

like 1.0.0.2024.06.01.12.06.11 but no more than four numbers are allowed in the version number, which causes an error.

If the extension uploads successfully, I get a link to a warning log, but when I tried to submit an extension with that version number, I just get 400 Bad Request, "Upload is not valid". with no link to the error log

aklinker1 commented 4 months ago

Ok, I assume this is something their linter would catch... Probably be a good idea to add https://www.npmjs.com/package/addons-linter, it just has a ton of dependencies, and I'm not sure it's worth it's size.

You could write a module that runs the linter before zipping, but I'd need to add some zip-specific hooks to make that easier.

But I'm surprised you were able to produce a manifest with a version like that in the first place, WXT should strip off the invalid digits, unless you explicitly override that behavior in the manifestGenerated hook.

modos189 commented 4 months ago

I don't use WXT, but yes, I overwrite the version number when building the beta version.

I don't think a linter should be added to publish-browser-extension. But it is strange that web-ext shows error log in cases when this project does not.

aklinker1 commented 4 months ago

I don't use WXT

Oh sorry, haha, for some reason, I thought I saw that in one of your comments. I'm starting to get all the issues for a couple of my repos mixed up.

I would just run the linter before you do a release, that should catch things like this. But yeah, it is weird that the API didn't provide a helpful error message.