Skip to content

[Bug] Impossible to trigger a solution aware cloud flow from a code app, app crashing or connection reference issue. #323

@GabrielCarlotti

Description

@GabrielCarlotti

Describe the bug

When a cloudflow is added to a Power Apps Code App via power-apps add-flow and the generated service is imported anywhere in the code, the deployed app fails to start with an "Internal Server Error". The error occurs at module load time, before any user interaction.

Removing the import and pushing again (pac code push) restores the app but do not load the last version of the app, removing the cloudflow and the references restores completely the working code app. The generated files alone are tolerated — only using them triggers the crash. This suggests getClient(dataSourcesInfo) eagerly resolves connection references at class-load time, and the required shared_logicflows connection cannot be resolved because no Logic flows connection exists in the environment, and there is no user-facing way to create one (or I didn't find one).

Steps to Reproduce

  1. Initialize a Code App with pac code init, push it, confirm it runs fine.
  2. Create a solution-aware cloud flow with a PowerApps (V2) manual trigger (no input parameters, empty body — does not matter). Confirm it can be invoked manually from the Power Automate UI and returns HTTP 202 and that it's well present in the solution.
  3. Run npx power-apps list-flows and copy the flow ID.
  4. Run npx power-apps add-flow --flowId — succeeds. Files are generated under
    src/generated/services/Service.ts, src/generated/models/Model.ts, .power/schemas/logicflows/.Schema.json. An entry is added to power.config.json referencing /providers/Microsoft.PowerApps/apis/shared_logicflows.
  5. pnpm (or any package manager) run build && pac code push -- succeeds. Open the app in the browser — still works fine at this stage, because nothing in the code imports the generated service yet, but if you try to make a quick modification in the app (move a text or change a text something like that), those modifications will not be pushed.
  6. Add a single import and a button in any page:

import { Test_cloud_flowService } from '@/generated/services/Test_cloud_flowService';

<Button onClick={async () => {
const result = await Test_cloud_flowService.Run({});
if (result.success) console.log('Flow triggered.');
else console.error('Flow failed:', result.error);
}}>
Trigger flow

  1. pnpm run build && pac code push — succeeds.
  2. Open the app in an incognito browser window.

Expected behavior

The app loads normally. Clicking the button invokes the flow and returns HTTP 202, matching the behavior documented at https://learn.microsoft.com/en-us/power-apps/developer/code-apps/how-to/add-flows.

Actual behavior

The app fails to start. The user sees a generic error page:

▎ The app didn't start correctly. Check that you are online, and try refreshing your browser. Encountered internal server
▎ error. The correlation Id is with the session id.

This occurs before any user interaction — the button is never even clicked. The error only occurs when the generated service is imported; leaving the generated files in the repo but never importing them allows the app to start.

A prior iteration of almost the same setup (when the service was imported and invoked, the button was triggering cloudflow that was refreshing a dataflow, both solutions aware and working when triggered manually) produced a different but related error at invocation time: the SDK made a POST to the wrong connector endpoint — it routed the call to the Power Query Dataflows connector instead of Logic flows, producing a 404:

POST https://.environment.api.powerplatform.com/connectors/runtime/invoke/
scaleGroups/france/shards/15/
apis/dataflows/connections/shared-dataflows-/triggers/manual/run
?api-version=2015-02-01-preview

{"statusCode": 404, "message": "Resource not found"}

Note the path is apis/dataflows/... when it should be apis/logicflows/.... This is consistent with the SDK falling back to a dependency connection (the dataflow used in the cloud flow's internal Refresh action) because no Logic flows connection exists to resolve shared_logicflows against.

I also came across an other error in the same setup where it was saying :

Execute operation failure: Connection reference not found: test_cloud_flow

This connection reference in the power.config.json was matching the Display Name : Logic flows but was nowhere to be found in the solution nor in the environment.

Attempted workarounds that did not produce a Logic flows connection:

  • Searching "Logic flows" in Power Apps → Connections → + New connection: the connector is not listed.
  • Creating a throwaway Canvas app, adding the flow via the Power Automate pane, wiring a button with OnSelect = FlowName.Run(), previewing and clicking the button: no prompt, no connection created.

After these attempts, the environment still shows zero Logic flows connections, although the flow itself has valid internal connections (Power Query Dataflows, Dataverse) and runs correctly when triggered from the Power Automate UI.

Screenshots or Error Messages

Image

Environment information

  • Framework / build tool: Vite 7, React 19, TypeScript 5.9, TanStack Router, pnpm
  • Power Apps packages: @microsoft/power-apps@1.1.1, @microsoft/power-apps-cli@0.10.0, @microsoft/power-apps-vite@1.0.2
  • Platform CLI: pac Version: 1.52.1+gcca51f4 (.NET 9.0.15) (not latest to avoid a bug with KeyChain on auth on MacOS)
  • Environment region: France
  • Flow trigger type: PowerApps (V2) manual, solution-aware, no input parameters
  • Licences : Power Apps for Office 365, Power Apps Community (no need for Power automate Premium, even though the components of the flow were not premium in one case, because the flow triggered inside the code app doesn't require premium subscription according to Power Platform licence board)

Additional context

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions