Skip to content

wip: allow initializing dataset by id#566

Closed
Ankur Goyal (ankrgyl) wants to merge 1 commit intomainfrom
init-dataset-improvements
Closed

wip: allow initializing dataset by id#566
Ankur Goyal (ankrgyl) wants to merge 1 commit intomainfrom
init-dataset-improvements

Conversation

@ankrgyl
Copy link
Contributor

No description provided.

Comment on lines +2562 to +2566
if (!isEmpty(datasetId)) {
throw new Error(
"Cannot specify datasetId and project or dataset name",
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The conditional check if (!isEmpty(datasetId)) is located inside an else block that only executes when datasetId is falsy, making this validation ineffective. To properly prevent users from specifying both a datasetId and project/dataset name parameters simultaneously, this validation should be moved outside the if/else structure, before line 2540.

A more effective approach would be:

if (datasetId && (!isEmpty(project) || !isEmpty(dataset))) {
  throw new Error(
    "Cannot specify datasetId and project or dataset name"
  );
}

if (datasetId) {
  // fetch existing dataset logic
} else {
  // create new dataset logic
}
Suggested change
if (!isEmpty(datasetId)) {
throw new Error(
"Cannot specify datasetId and project or dataset name",
);
}
if (datasetId && (!isEmpty(project) || !isEmpty(dataset))) {
throw new Error(
"Cannot specify datasetId and project or dataset name",
);
}

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If this PR is still relevant, please leave a comment, push an update, or remove the stale label. Thank you for your contributions!

@github-actions github-actions bot added the stale label Mar 14, 2026
@github-actions
Copy link

This pull request was closed because it has been inactive for 21 days (14 days of inactivity before being marked stale, plus 7 additional days). If this PR is still relevant, please feel free to reopen it. Thank you!

@github-actions github-actions bot closed this Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants