Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sanity migration run <migration_id> --project <project_id> --dataset <dataset> throws an error #7452

Open
mjablons opened this issue Aug 30, 2024 · 1 comment

Comments

@mjablons
Copy link

Describe the bug

when running a migration command with project and dataset options i.e.:

sanity migration run <migration_id> --project <project_id> --dataset <dataset>

where both project_id and dataset are defined and correct an error is thrown:

Error: sanity.cli.js does not contain a project identifier ("api.projectId"), which is required for the Sanity CLI to communicate with the Sanity API

To Reproduce

  1. create a simple migration script with sanity,
    sanity migration create
    and follow the prompt
  2. make sure there is no sanity.cli.js in your codebase
  3. according to the prompt:

Migration created!

Next steps:
Open /code/migrations/migration_id/index.ts in your code editor and write the code for your migration.
Dry run the migration with:
sanity migration run migration_id --project=<projectId> --dataset <dataset>
Run the migration against a dataset with:
sanity migration run migration_id --project=<projectId> --dataset <dataset> --no-dry-run

edit the script and run it as:
sanity migration run migration_id --project=real_project_id --dataset real_dataset

  1. you will get an error specified above

Expected behavior

My assumption is that b/c I provide the project id and dataset name in the command I do not need to specify a separate configuration file i.e. sanity.cli.ts. Indeed, creating such a file and providing project id and dataset names in there causes the command to run without any error. But why then I have a possibility to run this command specifying the needed parameters as the command options?

Screenshots
If applicable, add screenshots to help explain your problem.

Which versions of Sanity are you using?

3.56.0

Copy link
Member

Hi @mjablons thank you for reporting and all the details added.

We can reproduce it internally and the bug has been added to triage, we will keep this issue updated once it's fixed.

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

No branches or pull requests

2 participants