Skip to content

fix(core): accept contexts in executeUpload, clarify provider targeting docs#373

Merged
rvagg merged 6 commits intomasterfrom
rvagg/upload-dx
Mar 31, 2026
Merged

fix(core): accept contexts in executeUpload, clarify provider targeting docs#373
rvagg merged 6 commits intomasterfrom
rvagg/upload-dx

Conversation

@rvagg
Copy link
Copy Markdown
Member

@rvagg rvagg commented Mar 23, 2026

Closes: #372

Also discussing in here: FilOzone/synapse-sdk#690

I think the root problem is the migration pain and change of concepts that the SDK is pushing. Dealbot probably doesn't need to be touching contexts directly but we previously encouraged that as the path.

So the "fix" here is twofold: just accept a contexts argument if you want to provide it, and improve the docs to be much more explicit about what's going on.

@FilOzzy FilOzzy added team/filecoin-pin "Filecoin Pin" project is a stakeholder for this work. team/fs-wg FOC working group is a stakeholder for this work, and thus wants to track it on their project board. labels Mar 23, 2026
@FilOzzy FilOzzy added this to FOC Mar 23, 2026
@github-project-automation github-project-automation bot moved this to 📌 Triage in FOC Mar 23, 2026
@BigLep BigLep requested review from SgtPooki and Copilot and removed request for SgtPooki March 23, 2026 15:29
@BigLep BigLep moved this from 📌 Triage to 🔎 Awaiting review in FOC Mar 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses confusing provider targeting in the upload API by allowing callers to pass pre-resolved Synapse storage contexts through executeUpload, and by updating option docs to clarify how provider IDs vs data set IDs vs contexts should be used.

Changes:

  • Add contexts?: StorageContext[] support to executeUpload and uploadToSynapse by passing it through to the Synapse SDK upload call.
  • Add runtime validation in executeUpload to prevent combining multiple targeting mechanisms (contexts, providerIds, dataSetIds).
  • Update option documentation across upload-related interfaces to clarify recommended targeting patterns.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/core/upload/synapse.ts Introduces contexts to the lower-level Synapse upload helper and forwards it into SDK upload options.
src/core/upload/index.ts Adds contexts to executeUpload, validates mutually-exclusive targeting options, and forwards contexts into upload options.
src/common/upload-flow.ts Updates docs/comments for provider/data-set targeting to reduce DX confusion.
Comments suppressed due to low confidence (1)

src/core/upload/synapse.ts:286

  • SynapseUploadOptions.contexts is documented as mutually exclusive with providerIds, dataSetIds, and copies, but uploadToSynapse currently forwards all of these fields independently. Since uploadToSynapse is a public helper (used outside executeUpload), consider adding a mutual-exclusion guard here as well (or prioritizing contexts and ignoring the others) to keep runtime behavior aligned with the docs.
  // Pass through context selection options
  if (options.contexts != null) {
    uploadOptions.contexts = options.contexts
  }
  if (options.copies != null) {
    uploadOptions.copies = options.copies
  }
  if (options.providerIds != null) {
    uploadOptions.providerIds = options.providerIds
  }
  if (options.dataSetIds != null) {
    uploadOptions.dataSetIds = options.dataSetIds
  }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rvagg
Copy link
Copy Markdown
Member Author

rvagg commented Mar 30, 2026

I've also added source metadata matching in this PR as described in FilOzone/dealbot#402 (comment) - dealbot puts source: 'dealbot' in the Synapse instance and tries to use it to find data sets, which it never can, because we clobber it here unless it's an explicit option to executeUpload(). So now we're checking for all the possible places it can be set. There's a type override in here until FilOzone/synapse-sdk#701 is merged and released and we get a getter on StorageManager for source.

@rvagg rvagg requested a review from juliangruber March 30, 2026 04:50
@rjan90 rjan90 added this to the M4.2: mainnet GA milestone Mar 30, 2026
@rvagg rvagg force-pushed the rvagg/upload-dx branch from 3bdf0fb to 5800b7a Compare March 31, 2026 11:08
@rvagg rvagg merged commit b307beb into master Mar 31, 2026
17 of 18 checks passed
@rvagg rvagg deleted the rvagg/upload-dx branch March 31, 2026 11:20
@github-project-automation github-project-automation bot moved this from 🔎 Awaiting review to 🎉 Done in FOC Mar 31, 2026
@rvagg
Copy link
Copy Markdown
Member Author

rvagg commented Mar 31, 2026

Probably should have been a feat because of the contexts. Sorry.

Copy link
Copy Markdown
Member

@juliangruber juliangruber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team/filecoin-pin "Filecoin Pin" project is a stakeholder for this work. team/fs-wg FOC working group is a stakeholder for this work, and thus wants to track it on their project board.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

executeUpload has confusing DX

6 participants