You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running a query with 'Execture Query' in the Sanity.io VSCode extension results in a "Configuration must contain projectId" when sanity.cli.ts config file is set up to get projectId and dataset from env variables defined in a .env.local -file in the project root.
The sanity cli tool works (pnpm exec sanity dataset list)
Add SANITY_PROJECT_ID and SANITY_DATASET to .env.local
Go to a defined groq query in the project
Click on Execute Query above the query
See error "Configuration must contain projectId" in the VSCode Notification
Expected behavior
The expected behaviour is that the VSCode Sanity.io plugin is able to parse and use the sanity.cli.ts config file the same way the sanity cli tool does.
The project ID and dataset used is determined by finding sanity.cli.ts in the workspace. If multiple files are found, the extension will prompt you to select one.
Renaming .env.local to .env was also attempted, but did not resolve the issue or change the outcome.
If, in sanity.cli.ts, the projectId and dataset is replaced with static strings Sanity.io in VSCode works, this happens only if the values are attempted read from the env variables / env-var config file.
Screenshots
Which versions of Sanity are you using?
VSCode extension Developer tools for applications powered by Sanity.io v0.2.1
pnpm exec sanity versions
@sanity/cli (global) 3.64.3 (up to date)
@sanity/asset-utils 2.2.0 (up to date)
@sanity/dashboard 4.1.0 (up to date)
@sanity/icons 3.4.0 (up to date)
@sanity/image-url 1.1.0 (up to date)
@sanity/preview-url-secret 1.6.21 (latest: 2.0.4)
@sanity/react-loader 1.10.20 (up to date)
@sanity/vision 3.64.3 (up to date)
sanity 3.64.3 (up to date)
What operating system are you using?
MacOs 15.1
Which versions of Node.js / npm are you running?
nodejs: v20.17.0
npm: v10.8.2
Additional context
This issue seams related and increase the expectation for the ability to read env variables from file #17
This is within a nextjs project, but since the sanity cli tool works with the .env.local -file I expect this to work with the Sanity VSCode extension as well.
Also attempted to explicitly read the env-conf with NextJs tooling but resulted in the same issue. These line was added to the sanity.cli.ts file:
I've experienced the same problem and I was expecting the plugin to read the data from the sanity.cli.ts file , regardless of the fact that the data is coming from a .env file.
Describe the bug
Running a query with 'Execture Query' in the Sanity.io VSCode extension results in a "Configuration must contain
projectId
" whensanity.cli.ts
config file is set up to get projectId and dataset from env variables defined in a .env.local -file in the project root.The sanity cli tool works (
pnpm exec sanity dataset list
)To Reproduce
Steps to reproduce the behavior:
projectId
" in the VSCode NotificationExpected behavior
The expected behaviour is that the VSCode Sanity.io plugin is able to parse and use the sanity.cli.ts config file the same way the sanity cli tool does.
The same expectation after reading from https://github.com/sanity-io/vscode-sanity?tab=readme-ov-file#execute-groq-queries which does not state that defining this statically is required:
Renaming .env.local to .env was also attempted, but did not resolve the issue or change the outcome.
If, in sanity.cli.ts, the projectId and dataset is replaced with static strings Sanity.io in VSCode works, this happens only if the values are attempted read from the env variables / env-var config file.
Screenshots
Which versions of Sanity are you using?
VSCode extension Developer tools for applications powered by Sanity.io v0.2.1
What operating system are you using?
MacOs 15.1
Which versions of Node.js / npm are you running?
nodejs: v20.17.0
npm: v10.8.2
Additional context
This issue seams related and increase the expectation for the ability to read env variables from file #17
This is within a nextjs project, but since the sanity cli tool works with the .env.local -file I expect this to work with the Sanity VSCode extension as well.
Also attempted to explicitly read the env-conf with NextJs tooling but resulted in the same issue. These line was added to the sanity.cli.ts file:
The text was updated successfully, but these errors were encountered: