Skip to content

feat(state-machine): record failure code and step on component results - #3031

Open
madhavilosetty-intel wants to merge 1 commit into
feat/2999-3-activation-failuresfrom
feat/2999-4-component-failures
Open

madhavilosetty-intel wants to merge 1 commit into
feat/2999-3-activation-failuresfrom
feat/2999-4-component-failures

Conversation

@madhavilosetty-intel

@madhavilosetty-intel madhavilosetty-intel commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

PR Checklist

  • Unit Tests have been added for new changes
  • API tests have been updated if applicable (not applicable: no REST API change)
  • All commented code has been removed
  • If you've added a dependency, you've ensured license is compatible with Apache 2.0 and clearly outlined the added dependency. (no new dependency)

What are you changing?

Fourth of five stacked PRs for #2999.

Network (wired, wireless), CIRA, proxy, TLS, features and unconfiguration failures now record the catalog code, the step that failed and the AMT return value on their component result, next to the existing Details text.

A non-zero method ReturnValue is not decoded: for example ReturnValue 1 on AddWiFiSettings reports AMT_METHOD_FAILED with AmtReturnValue: 1.

Bug fix included: unconfiguration listened for an ONFAILURE event that the error machine never sends (it sends ONFAILED, like every other machine expects). When the error machine gave up, the unconfiguration machine sat in ERROR forever. It now transitions to FAILURE and records the failed step.

Anything the reviewer should know when reviewing this PR?

  • Component failures still do not end the flow, so they arrive in a success message with no Error block. rpc-go turns them into an exit code in feat(rps): render structured provisioning error and map exit code rpc-go#1716.
  • GenerateKeyPair and GeneratePKCS10RequestEx are AMT calls, so their failures carry no RPS step code: an AMT rejection resolves to the WSMAN_* code with HttpStatus, a timeout to WSMAN_TIMEOUT. RPS_CERT_GENERATION_FAILED is used only where RPS or rpc-go generates the certificate.
  • Stacked on the previous PR: review only the top commit. The base moves to main as the earlier PRs merge.

Stack, in merge order:

  1. Error catalog and failure types
  2. Failure helpers in the state machine layer
  3. Activation and deactivation send the Error block
  4. Component results carry code, step and return value (this PR)
  5. Maintenance tasks send the Error block

If the there are associated PRs in other repositories, please link them here (i.e. device-management-toolkit/repo#365 )

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Two moderate data-propagation issues cause structured failures from the feature-configuration and unconfiguration child machines to be discarded before reaching the activation response.

2 open issues
What changed in this PR

Extends provisioning state machines with structured failure diagnostics, including catalog codes, failed steps, and AMT/CIM return values, while preserving existing status text and progress messages.

Changes:

  • Adds structured failure handling across wired, wireless, proxy, CIRA, TLS, network, feature, and unconfiguration flows.
  • Maps service-specific AMT, Wi-Fi, and CIM return values to catalog codes.
  • Expands unit tests for timeout, database, secret-provider, transport, and component-result behavior.
File Description
src/​stateMachines/​wiredNetworkConfiguration.ts Records structured wired-network failure details and component results.
src/​stateMachines/​wiredNetworkConfiguration.test.ts Tests wired timeout and database failure metadata.
src/​stateMachines/​wifiNetworkConfiguration.ts Maps Wi-Fi return values and records structured wireless failures.
src/​stateMachines/​wifiNetworkConfiguration.test.ts Tests Wi-Fi catalog mappings, return values, and failure metadata.
src/​stateMachines/​unconfiguration.ts Adds structured failure details to unconfiguration paths.
src/​stateMachines/​unconfiguration.test.ts Tests HTTP failure classification during unconfiguration.
src/​stateMachines/​tls.ts Adds structured TLS failure details and component-result reporting.
src/​stateMachines/​tls.test.ts Tests TLS timeout and component-result metadata.
src/​stateMachines/​proxyConfiguration.ts Maps proxy return values and records structured proxy failures.
src/​stateMachines/​proxyConfiguration.test.ts Tests proxy return-value, database, transport, and thrown-error failures.
src/​stateMachines/​networkConfiguration.ts Records failures from general network configuration steps.
src/​stateMachines/​networkConfiguration.test.ts Updates network state-machine mocks for structured failure helpers.
src/​stateMachines/​featuresConfiguration.ts Adds structured failure construction to feature configuration steps.
src/​stateMachines/​featuresConfiguration.test.ts Tests feature configuration timeout failure metadata.
src/​stateMachines/​ciraConfiguration.ts Adds structured CIRA failure reporting and CIM return-value handling.
src/​stateMachines/​ciraConfiguration.test.ts Tests CIRA method, MPS, timeout, and secret-provider failures.

Review effort: Lite

Comment thread src/stateMachines/unconfiguration.ts Resolved
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-3-activation-failures branch from 7b3a8a4 to f69dbe8 Compare November 13, 2026 21:01
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-4-component-failures branch 2 times, most recently from 468d150 to 6eea6d8 Compare November 13, 2026 21:12
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-3-activation-failures branch from f69dbe8 to 66a7f64 Compare November 13, 2026 21:12
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-4-component-failures branch from 6eea6d8 to 3ebf33a Compare November 13, 2026 21:25
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-3-activation-failures branch from 66a7f64 to a7805a4 Compare November 13, 2026 21:25
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-4-component-failures branch from 3ebf33a to b5766c4 Compare November 16, 2026 21:29
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-3-activation-failures branch 2 times, most recently from 2b1458c to 8953175 Compare November 17, 2026 16:48
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-4-component-failures branch 2 times, most recently from 9bd615a to 8d6fcb0 Compare November 17, 2026 20:16
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-3-activation-failures branch 2 times, most recently from 78ad95a to e9ce9f4 Compare November 18, 2026 21:53
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-4-component-failures branch from 8d6fcb0 to 127f403 Compare November 18, 2026 21:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An active moderate finding remains because a TLS-setting failure path can omit the expected Unconfiguration result when no structured failure is assigned.

1 open issue
2 resolved since last review

Review effort: Lite

Comment thread src/stateMachines/unconfiguration.ts Resolved
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-3-activation-failures branch from e9ce9f4 to 0d35045 Compare November 19, 2026 20:27
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-4-component-failures branch 2 times, most recently from 12e1849 to a3c7402 Compare November 19, 2026 20:41
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-3-activation-failures branch from 0d35045 to adfbf8d Compare November 19, 2026 23:17
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-4-component-failures branch from a3c7402 to 443d648 Compare November 19, 2026 23:17
@rsdmike

rsdmike commented Nov 20, 2026

Copy link
Copy Markdown
Member

The ONFAILURE to ONFAILED change in unconfiguration is a real fix since it used to just hang, worth calling out in the description or splitting out. Component failures now publish fail events even when activation succeeds, which could confuse anything treating fail as the activation failed. Also GenerateKeyPair and the CSR signing steps get tagged RPS_CERT_GENERATION_FAILED even when it's AMT rejecting them.

@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-3-activation-failures branch from adfbf8d to 6aaee07 Compare November 20, 2026 22:23
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-4-component-failures branch from 443d648 to 0abf048 Compare November 20, 2026 22:40
Network, CIRA, proxy, TLS, features and unconfiguration failures now carry
the catalog code, the step that failed and the AMT return value on their
component result, alongside the existing details text.

Related to #2999
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-4-component-failures branch from 0abf048 to da432e9 Compare November 20, 2026 22:59
@madhavilosetty-intel

Copy link
Copy Markdown
Contributor Author

The ONFAILURE to ONFAILED fix is now called out in the description as a bug fix. GenerateKeyPair and GeneratePKCS10RequestEx no longer carry an RPS step code, so an AMT rejection resolves to the WSMAN_* code with HttpStatus, and a timeout to WSMAN_TIMEOUT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants