Describe the bug
pac code add-data-source returns a 404 error when using an @envvar: reference for the -d (dataset) flag with a SQL Server connector. The same command succeeds when the literal dataset string is passed directly.
The 404 error URL in the output shows %252C where a comma should appear in the dataset path, which suggests the value may be getting encoded differently when resolved from an environment variable vs. passed as a literal string.
Steps to Reproduce
- Create a Power Platform environment variable (e.g.,
kumo_ISVarSQLString) with the value abc-server.database.windows.net,abc-database
- Run:
pac code add-data-source -a shared_sql -c <connection-id> -d "@envvar:kumo_ISVarSQLString" -t "sweepstakes"
- Observe the 404 error
- Run the same command with the literal string instead of the
@envvar: reference:
pac code add-data-source -a shared_sql -c <connection-id> -d "abc-server.database.windows.net,abc-database-qa" -t "sweepstakes"
- This succeeds
Expected behavior
The command should succeed with the @envvar: reference the same way it does with the literal string, resolving the environment variable and using its value as the dataset.
Actual behavior
The command fails with a 404. The error URL contains %252C in the dataset path where a single %2C (encoded comma) would be expected:
HTTP error status: 404 for GET https://<env-id>.03.common.usa002.azure-apihub.net/apim/sql/<connection-id>/v2/$metadata.json/datasets/abc-server.database.windows.net%252Cabc-database-qa/tables/sweepstakes
Screenshots or Error Messages
Failing — with @envvar: reference:
PS> pac code add-data-source -a shared_sql -c 8609e758969641f99f2da4347e93d1de -d "@envvar:kumo_ISVarSQLString" -t "sweepstakes"
Connected as ...
HTTP error status: 404 for GET https://e38c802f-8aab-e352-843e-56934dfb810d.03.common.usa002.azure-apihub.net/apim/sql/<connection-id>/v2/$metadata.json/datasets/abc-server.database.windows.net%252Cabc-database-qa/tables/sweepstakes
Working — with literal string (same connection, same table):
PS> pac code add-data-source -a shared_sql -c <connection-id> -d "abc-server.database.windows.net,abc-database-qa" -t "sweepstakes"
Connected as ...
(succeeds — model file generated, power.config.json updated)
Environment information
- Framework/build tool: React 19.2 + Vite 7.2 + TypeScript 5.9
- Power Apps packages:
@microsoft/power-apps v1.0.3, @microsoft/power-apps-vite v1.0.2
- PAC CLI version:
- Connection/components: SQL Server connector (
shared_sql)
- OS: Windows
Additional context
Describe the bug
pac code add-data-sourcereturns a 404 error when using an@envvar:reference for the-d(dataset) flag with a SQL Server connector. The same command succeeds when the literal dataset string is passed directly.The 404 error URL in the output shows
%252Cwhere a comma should appear in the dataset path, which suggests the value may be getting encoded differently when resolved from an environment variable vs. passed as a literal string.Steps to Reproduce
kumo_ISVarSQLString) with the valueabc-server.database.windows.net,abc-database@envvar:reference:Expected behavior
The command should succeed with the
@envvar:reference the same way it does with the literal string, resolving the environment variable and using its value as the dataset.Actual behavior
The command fails with a 404. The error URL contains
%252Cin the dataset path where a single%2C(encoded comma) would be expected:Screenshots or Error Messages
Failing — with
@envvar:reference:Working — with literal string (same connection, same table):
Environment information
@microsoft/power-appsv1.0.3,@microsoft/power-apps-vitev1.0.2shared_sql)Additional context
sweepstakes-server.database.windows.net,sweepstakes-database-qawith no pre-encoding.pacinstall andnpx pac.-dto generate the model file, then manually editpower.config.jsonto replace the literal dataset value with the@envvar:reference.