Skip to content

fix(upload): upload URLs the batch API returns under another spelling - #1047

Open
LinoGiger wants to merge 1 commit into
mainfrom
fix(upload)/upload-urls-the-batch-api-returns-under-another-spelling
Open

LinoGiger wants to merge 1 commit into
mainfrom
fix(upload)/upload-urls-the-batch-api-returns-under-another-spelling

Conversation

@LinoGiger

Copy link
Copy Markdown
Collaborator

Why

The batch-upload API answers with each URL as it normalised it, and the uploader keyed its cache and its completion callback on that spelling. A URL the API rewrote uploads fine, then its datapoint fails with One or more required assets failed to upload, and retry() fails the same way every time. On the test environment 6 of 6 valid spellings failed: a trailing newline (a line read from a text file), a trailing space, an upper-case scheme or host, :443, and %2D for -.

Flow

flowchart LR
  sdk["BatchAssetUploader._process_single_batch"]:::changed -->|"POST /asset/batch-upload"| asset["asset service"]
  sdk -->|"GET /asset/batch-upload/{id} (URLs as normalised)"| asset
  sdk ==>|"POST /asset/url, only for URLs returned under another spelling"| asset
  sdk -->|"completed URLs, caller's spelling"| ds["RapidataDataset.add_datapoints"]
  classDef new fill:#d3f9d8,stroke:#2f9e44,color:#000
  classDef changed fill:#fff3bf,stroke:#f08c00,color:#000
  classDef removed fill:#ffe3e3,stroke:#e03131,color:#000,stroke-dasharray:4
Loading

Decisions

  • A submitted URL with no result item under its own spelling goes through the single-URL endpoint, which returns the file name directly. Matching by position was rejected: the result list has no guaranteed order, and a wrong match would attach the wrong file to a datapoint without an error. Rebuilding the server's normalisation in Python was rejected too: it can only approximate it.
  • Result items under a spelling nobody submitted are skipped, so a rewritten URL that fails is reported once, under the caller's spelling and with the reason from the single upload.
  • The server could also return the URL as submitted, which would fix released SDK versions as well; this change stays correct either way.

Verified

Three new tests, two of which fail on main. On the test environment the same 8-URL job definition (6 rewritten spellings, 1 untouched, 1 rewritten and missing) went from 7 failed datapoints on main to 7 created, with the missing file reported as The remote asset could not be retrieved.

Agent skill: nothing the skill documents changed, so this needs the skill-unchanged-approved label.

🔗 Session: https://poseidon.rapidata.internal/chat/ves-167c2yznsvyzh9

🤖 Generated with Claude Code

The batch-upload API answers with each URL as it normalised it (trimmed,
lower-cased scheme and host, default port dropped, escapes decoded). The
uploader keyed its cache and its completion callback on that spelling,
so a URL the API rewrote never matched its datapoint: the upload
succeeded and the datapoint failed with "One or more required assets
failed to upload", on every retry.

A submitted URL with no item under its own spelling is now uploaded
through the single-URL endpoint, which answers with the file name
directly, and a failure is reported under the caller's spelling with its
real reason.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: lino@rapidata.ai <68745352+LinoGiger@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

⚠ Agent skill not updated

This PR does not modify src/rapidata/_skill/. That directory is the agent skill that ships in every SDK release and that coding agents read through python -m rapidata skill.

Before merging, pick one:

  1. The change affects what an agent needs to know (new or renamed API, changed parameter, default or result field, new gotcha): update src/rapidata/_skill/SKILL.md (or a companion guide next to it) in this PR.
  2. Nothing the skill documents changed: a reviewer applies the skill-unchanged-approved label. New commits remove the label again.

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.

2 participants