Skip to content

pac code add-data-source returns 404 when using @envvar: for SQL connector dataset #352

@stormea36

Description

@stormea36

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

  1. Create a Power Platform environment variable (e.g., kumo_ISVarSQLString) with the value abc-server.database.windows.net,abc-database
  2. Run:
    pac code add-data-source -a shared_sql -c <connection-id> -d "@envvar:kumo_ISVarSQLString" -t "sweepstakes"
    
  3. Observe the 404 error
  4. 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"
    
  5. 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

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions