Skip to content

feat(activation): report structured failure for activation and deactivation - #3030

Open
madhavilosetty-intel wants to merge 1 commit into
feat/2999-2-failure-helpersfrom
feat/2999-3-activation-failures
Open

madhavilosetty-intel wants to merge 1 commit into
feat/2999-2-failure-helpersfrom
feat/2999-3-activation-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?

Third of five stacked PRs for #2999. This is the first one that changes what rpc-go receives.

A failed activation or deactivation now sends an optional Error object inside the final status message:

Field Meaning
Code Stable code, e.g. RPS_ACTIVATION_FAILED, WSMAN_TIMEOUT, RPS_CERT_INVALID
Component Activation or Deactivation
Step State machine step that failed, e.g. ADMIN_SETUP
Reason Readable description of the code
AmtReturnValue Optional. Raw method ReturnValue
HttpStatus Optional. HTTP status of the AMT response
WsmanCall Optional. The call AMT was answering, e.g. IPS_HostBasedSetupService.AdminSetup
Detail Optional. Underlying error text; sent only for device-origin codes

The same block goes to one RPS log line and one MQTT fail event.

Anything the reviewer should know when reviewing this PR?

  • Additive only: legacy Status text and existing fields are unchanged, and older rpc-go releases ignore the new key.
  • Detail is dropped for RPS_* codes before the message is sent, because that text can name internal hosts; it stays in the RPS log line.
  • A non-zero method ReturnValue is not decoded: the step keeps its own code and the raw number is sent in AmtReturnValue with the WsmanCall.
  • When AdminSetup or UpgradeClientToAdmin fails and RPS deactivates the device, the reported failure is the setup step and its return value, not the deactivation.
  • 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 (this PR)
  4. Component results carry code, step and return value
  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

Active moderate and critical findings remain in the activation and deactivation reporting paths, including stale error state, lost child failure details, and unsanitized failure data published over MQTT.

6 open issues
What changed in this PR

Adds structured failure reporting for activation and deactivation flows while preserving existing status text and response fields. Failures now include stable codes, components, state-machine steps, and optional AMT/WSMAN diagnostics for RPC, logging, and MQTT consumers.

Changes:

  • Captures and propagates structured failures across activation and deactivation state transitions.
  • Reports failure details in final status messages, logs, and MQTT events.
  • Extends activation and deactivation tests for structured failure propagation and response reporting.
File Description
src/​stateMachines/​deactivation.ts Records and reports structured deactivation failures, including cleanup-related failure context.
src/​stateMachines/​deactivation.test.ts Tests structured failure capture and propagation for deactivation cleanup errors.
src/​stateMachines/​activation.ts Records, propagates, and reports structured activation failures, including cleanup and child-flow handling.
src/​stateMachines/​activation.test.ts Tests activation failure codes, steps, return values, deactivation preservation, and final response reporting.

Review effort: Lite

Comment thread src/stateMachines/activation.ts Resolved
Comment thread src/stateMachines/deactivation.ts Resolved
Comment thread src/stateMachines/activation.ts Resolved
Comment thread src/stateMachines/activation.ts Resolved
Comment thread src/stateMachines/activation.ts Resolved
Comment thread src/stateMachines/deactivation.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-2-failure-helpers branch 2 times, most recently from 26f951b to 310e2bb Compare November 13, 2026 21:12
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-3-activation-failures branch 2 times, most recently from 66a7f64 to a7805a4 Compare November 13, 2026 21:25
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-2-failure-helpers branch from 310e2bb to ebc5f26 Compare November 16, 2026 21:30
@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-2-failure-helpers branch 2 times, most recently from 82f8be8 to d375fb6 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-2-failure-helpers branch from d375fb6 to 5e4b87a 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.

Comment thread src/stateMachines/activation.ts Resolved
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-3-activation-failures branch 2 times, most recently from 0d35045 to adfbf8d Compare November 19, 2026 23:17
@madhavilosetty-intel
madhavilosetty-intel force-pushed the feat/2999-2-failure-helpers branch from 5e4b87a to 4c64e01 Compare November 19, 2026 23:17
@rsdmike

rsdmike commented Nov 20, 2026

Copy link
Copy Markdown
Member

Ran the stack on an AMT 18 against RPS and the output matches main for ccm/acm with tls, cira and the maintenance commands, so no breaking changes that I can see. Small one, the CCM failure gets recorded as CHECK_CLIENT_SETUP but the state is CHECK_SETUP, and the deactivate path sending the Error block could use a test.

…vation

A failed activation or deactivation now sends an additive Status.Error
block with a catalog code, the component and step that failed, the WSMAN
call AMT was answering, a readable reason and the AMT return value or HTTP
status when there is one. The same block goes to one RPS log line and an
MQTT event. Legacy status text is unchanged.

Related to #2999
@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 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for running the stack on hardware. The CCM check now records CHECK_SETUP to match the state name, and deactivation has tests for the Error block on the wire (step and code sent with Detail dropped, fallback to RPS_DEACTIVATION_FAILED, and success clearing a stale Error).

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