Skip to content

Conversation

@beck-8
Copy link

@beck-8 beck-8 commented Dec 25, 2025

No description provided.

@BigLep BigLep added team/fs-wg FOC working group is a stakeholder for this work, and thus wants to track it on their project board. team/filecoin-pin "Filecoin Pin" project is a stakeholder for this work. labels Jan 28, 2026
@BigLep BigLep requested a review from Copilot January 28, 2026 19:15
@FilOzzy FilOzzy added this to FOC Jan 28, 2026
@BigLep BigLep requested a review from SgtPooki January 28, 2026 19:15
@github-project-automation github-project-automation bot moved this to 📌 Triage in FOC Jan 28, 2026
@BigLep
Copy link
Member

BigLep commented Jan 28, 2026

@beck-8 : sorry this got missed. It wasn't added to the board, which is why I hadn't seen it. It has been now.

@SgtPooki : I have assigned this to you, but feel free to assign to someone else or note if we shouldn't get distracted by this currently.

Copy link
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

Adds CLI support for selecting an existing dataset or forcing creation of a new dataset when running the add command.

Changes:

  • Adds --dataset <id> and --new-dataset flags to the add CLI command and maps them into AddOptions.
  • Extends AddOptions with datasetId / createNewDataset and forwards these into createStorageContext dataset options.
  • Updates unit tests to cover dataset option forwarding into storage context.

Reviewed changes

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

File Description
src/commands/add.ts Adds new CLI flags and maps them into AddOptions passed to runAdd.
src/add/types.ts Extends AddOptions to include dataset selection fields.
src/add/add.ts Forwards dataset selection fields into CreateStorageContextOptions.dataset.
src/test/unit/add.test.ts Adds assertions that dataset selection fields are passed into storage context creation.

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

Comment on lines 13 to 14
.option('--dataset <id>', 'ID of the existing dataset to use')
.option('--new-dataset', 'Create a new dataset instead of using an existing one')
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

--dataset and --new-dataset can currently be provided together, which produces ambiguous CLI intent (and results in both datasetId and createNewDataset potentially being set). Please enforce mutual exclusivity (e.g., validate in the action handler and throw a clear error when both are set).

Copilot uses AI. Check for mistakes.
Comment on lines 25 to 32
const addOptions: AddOptions = {
...addOptionsFromCli,
filePath: path,
...(dataset && { datasetId: parseInt(dataset, 10) }),
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

parseInt(dataset, 10) is used without validation. If the user passes a non-integer (e.g., "abc" or "123x"), this can yield NaN or a surprising value and the flag will be silently ignored downstream. Please validate that the parsed ID is a positive safe integer and surface a helpful error when invalid.

Suggested change
const addOptions: AddOptions = {
...addOptionsFromCli,
filePath: path,
...(dataset && { datasetId: parseInt(dataset, 10) }),
let datasetId: number | undefined
if (dataset !== undefined) {
const trimmed = String(dataset).trim()
// Ensure the dataset ID is a positive safe integer and fully numeric
if (!/^[0-9]+$/.test(trimmed)) {
console.error(`Invalid value for --dataset: "${dataset}". Expected a positive integer ID.`)
process.exit(1)
}
const parsed = Number(trimmed)
if (!Number.isSafeInteger(parsed) || parsed <= 0) {
console.error(`Invalid value for --dataset: "${dataset}". Expected a positive safe integer ID.`)
process.exit(1)
}
datasetId = parsed
}
const addOptions: AddOptions = {
...addOptionsFromCli,
filePath: path,
...(datasetId !== undefined && { datasetId }),

Copilot uses AI. Check for mistakes.
logger: expect.anything(),
})
)
})
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The earlier metadata test now only asserts initializeSynapse/createStorageContext and no longer verifies that metadata is forwarded into the upload call (e.g., via performUpload). Either restore the upload-side assertion or adjust the test description/expectations so it matches the behavior being verified.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

@beck-8 can you ensure we don't remove the metadata assertion

Copy link
Collaborator

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

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

makes sense, but one callout:

naming conventions are DataSet is two separate words, so we should stick to that, or add an alias at the very least. dataSet or data-set over dataset, but we have an alias in other places, so I'm good with dataset as long as we also have data-set in the CLI.

vars internally should use camelCase

@github-project-automation github-project-automation bot moved this from 📌 Triage to ⌨️ In Progress in FOC Jan 28, 2026
@beck-8 beck-8 force-pushed the feature/add-dataset-flags branch from d66111a to 3631fa0 Compare January 29, 2026 05:39
@beck-8 beck-8 changed the title feat: add --dataset and --new-dataset flags to add command feat: add --data-set and --new-data-set flags to add command Jan 29, 2026
Copy link
Collaborator

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

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

thanks for the quick updates @beck-8.. a few last things

logger: expect.anything(),
})
)
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

@beck-8 can you ensure we don't remove the metadata assertion

Comment on lines +14 to +16
// Add data set selection options
addCommand.addOption(new Option('--data-set <id>', 'ID of the existing data set to use'))
addCommand.addOption(new Option('--new-data-set', 'Create a new data set instead of using an existing one'))
Copy link
Collaborator

Choose a reason for hiding this comment

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

idk if this solves the mutual exclusivity problem brought up by a different copilot comment. you will want .conflicts('otherOption') for these

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.

3 participants