Skip to content

[Bug] 1.0 Upgrade - Stored Procedure - Client Generates Invalid Input Params #190

@johnyenter-briars

Description

@johnyenter-briars

Describe the bug

  • After updating to Power Apps SDK 1.0 (^1.0.3) - Stored Procedure metadata / parameters incorrectly parsed

Steps to Reproduce

{
  "name": "vite",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "tsc -b && vite build",
    "lint": "eslint .",
    "preview": "vite preview"
  },
  "dependencies": {
    "@fluentui-contrib/react-data-grid-react-window": "^1.4.2",
    "@fluentui/react-components": "^9.72.2",
    "@fluentui/react-datepicker-compat": "^0.6.22",
    "@microsoft/power-apps": "^1.0.3",
    "react": "^19.2.0",
    "react-dom": "^19.2.0",
    "uuid": "^13.0.0"
  },
  "devDependencies": {
    "@eslint/js": "^9.39.1",
    "@types/node": "^24.10.1",
    "@types/react": "^19.2.5",
    "@types/react-dom": "^19.2.3",
    "@vitejs/plugin-react": "^5.1.1",
    "eslint": "^9.39.1",
    "eslint-plugin-react-hooks": "^7.0.1",
    "eslint-plugin-react-refresh": "^0.4.24",
    "globals": "^16.5.0",
    "typescript": "~5.9.3",
    "typescript-eslint": "^8.46.4",
    "vite": "^7.2.4"
  }
}
  1. Deleted node modules - and re-installed
  2. ran npm run dev
  3. Inspected network traces in code app (running locally)
  4. Normal table calls (sql server connector) still work just fine
  5. Stored procedure's input parameters is malformed

Expected behavior

  • Example of the network call in the current live and correct app:
  • https://unitedstates-002.azure-apim.net/invoke
  • x-ms-request-url /apim/sql/49d2b9f70e2a42a89407d1648b01d2f1/v2/datasets/database.corp.foo.com,DATABASE/procedures/dbo.SP_StoredProcedure
  • Valid request: Image
  • This returns a valid data set:Image

Actual behavior

  • Example of network call in the local app (after updating to 1.0.3 sdk)
  • https://unitedstates-002.azure-apim.net/invoke
  • x-ms-request-url /apim/sql/49d2b9f70e2a42a89407d1648b01d2f1/v2/datasets/database.corp.foo.com,DATABASE/procedures/dbo.SP_StoredProcedure
  • Invalid request: Image
  • Returns no data set: Image
  • Note that the request 'body' is not longer a JSON object - but is instead a string. And as a result has lost the HouseholdId key

Environment information

  • Code apps is confirmed to be on (the code app has been pushed successfully in the very same environment)
  • Framework, build tool or relevant package used: [React,Vite, Webpack, etc] (the standard code-app setup generated via the CLI)
  • Connection components: [only SQL]
  • PAC CLI: Version: 2.2.1+g666525f (.NET Framework 4.8.9325.0)

Additional context

  • The current power.config.json:
{
  "appId": "62d2676c-8513-488e-a6a4-08f97837c2a4",
  "appDisplayName": "App Name",
  "description": null,
  "environmentId": "e3ef97eb-a6b2-47e2-acd6-3382fc9f0b62",
  "buildPath": "./dist",
  "buildEntryPoint": "index.html",
  "logoPath": "Default",
  "localAppUrl": "http://localhost:3000/",
  "connectionReferences": {
    "4bbe62d0-ffb9-47ad-bf2a-8f2d149b6884": {
      "id": "/providers/Microsoft.PowerApps/apis/shared_sql",
      "displayName": "SQL Server",
      "dataSources": [
        //..other sql data source ommitted
        "_4bbe62d0_ffb9_47ad_bf2a_8f2d149b6884_sp"
      ],
      "authenticationType": "windowsAuthentication",
      "sharedConnectionId": "/providers/Microsoft.PowerApps/apis/shared_sql/connections/49d2b9f70e2a42a89407d1648b01d2f1",
      "dataSets": {
        "database.corp.foo.com,DATABASE": {
          "dataSources": {
            //..other sql data source ommitted
            "_4bbe62d0_ffb9_47ad_bf2a_8f2d149b6884_sp": {}
          }
        }
      },
      "xrmConnectionReferenceLogicalName": "connection_name_here"
    }
  },
  "databaseReferences": {},
  "region": "prod",
  "version": "1.0"
}
  • Note: when we upgraded the app - it added the version config - but made no other changes
  • The current schema of the stored procedure service:
import { dataSourcesInfo } from '../../../.power/schemas/appschemas/dataSourcesInfo';
import type { IOperationResult } from '@microsoft/power-apps/data';
import { getClient } from '@microsoft/power-apps/data';
import type { SP_StoredProcedureResponse } from '../models/SP_GetLatestPositionsForHouseholdModel';

export class SP_StoredProcedureService {
  private static readonly dataSourceName = '_4bbe62d0_ffb9_47ad_bf2a_8f2d149b6884_sp';

  private static readonly client = getClient(dataSourcesInfo);

  public static async SP_StoredProcedure(HouseholdId?: string): Promise<IOperationResult<SP_StoredProcedureResponse >> {
    const params: { HouseholdId?: string } = { HouseholdId };
    const result = await SP_StoredProcedureService .client.executeAsync<{ HouseholdId?: string }, SP_StoredProcedureResponse >(
      {
        connectorOperation: {
          tableName: SP_StoredProcedureService .dataSourceName,
          operationName: 'SP_StoredProcedure',
          parameters: params
        },
      });
    return result;
  }
}
  • Note: in our code - the stored procedure is not actually called StoredProcedure - but i've edited the name for security
  • All connections in the Code app move through a singular connection reference
  • This code app also uses several SQL tables. Those appear to be unaffected and are working just fine

What We've Tried

  • I assumed this was a problem with the scaffolded (maybe the newer version of the PAC CLI generates a stored procedure scaffolding in a different way in 1.0
  • I removed the datasource - and re added (still through the connection referenece) - and the scaffolded code was generated exactly the same
  • I put a debugger statement in the SP_StoredProcedure method to confirm HouseholdId and params are valid - both are correct

Hypothesis

  • I hypothesize that something is wrong in the client.executeAsync that it's stripping part of params off - or maybe taking an incorrect Object.values from the input params.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions