NIP-96 uploads fail even when successful

Open Beginner friendly
#273 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
typescript
Domain
api

Research direction

Start at Nip96.upload, where the response status is checked after posting to the upload URL. Review the server response handling and confirm that a successful 202 Accepted upload is treated as successful rather than reported as an error. Done means uploads returning the documented successful status no longer throw.

Written by the indexing model from the issue text.

Description

Uploading files with Nip96.upload fail because of too strict status code handling. (tested with different servers)

The error:

Error uploading file: Error: Failed to upload file to https://files.sovbit.host/api/v2/media
    at Nip96.upload (index.mjs:7954:13)
    at async Object.onUpload (Editor.js:122:56)

The answer of the server:

Request URL: https://files.sovbit.host/api/v2/media
Request Method: POST
Status Code: 202 Accepted

The code that checks for the status code:

    if (res.status !== 200)
      throw new Error(`Failed to upload file to ${url}`);
Dominant language
TypeScript
Stars
453
Forks
126
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nostr-dev-kit/ndk

All issues in nostr-dev-kit/ndk

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.