Skip to content

Conversation

@kithwa
Copy link
Contributor

@kithwa kithwa commented Nov 28, 2025

  • map AMTStatusCodes detected in /amt/userConsentCode to more specific HTTP Status Codes instead of always 400 (Bad Request):
    • 0x0002 (NOT_READY) --> HTTP 409 (Conflict)
      • AMT device's OptInState is in conflict with the action ordered.
    • 0x0812 (UNSUPPORTED) --> HTTP 422 (Unprocessable Entity)
      • send request (POST/amt/userConsentCode) with wrong/typo in ConsentCode will encounter this error code.
  • added details in Response Body for more clarity.

PR Checklist

  • Unit Tests have been added for new changes
  • API tests have been updated if applicable
  • 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.

What are you changing?

Anything the reviewer should know when reviewing this PR?

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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances error handling for AMT user consent operations by mapping AMT-specific status codes to appropriate HTTP status codes and providing detailed error messages. Previously, all errors returned HTTP 400 (Bad Request); now specific AMT errors map to HTTP 409 (Conflict) for NOT_READY conditions and HTTP 401 (Unauthorized) for UNSUPPORTED operations.

Key Changes:

  • Introduced statusMapper.ts module with functions to map AMT return values to HTTP status codes and generate detailed error messages
  • Updated send.ts, request.ts, and cancel.ts to use the new status mapping and error formatting
  • Enhanced error responses with contextual information including suggestions and state-checking guidance

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/routes/amt/userConsent/statusMapper.ts New module providing AMT-to-HTTP status code mapping and detailed error message generation for user consent operations
src/routes/amt/userConsent/send.ts Updated to use status mapper for error responses and enhanced logging with return value details
src/routes/amt/userConsent/request.ts Updated to use status mapper for error responses and enhanced logging with return value details
src/routes/amt/userConsent/cancel.ts Updated to use status mapper for error responses, simplified conditional logic, and enhanced logging

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Cheah, Kit Hwa <kit.hwa.cheah@intel.com>
@madhavilosetty-intel madhavilosetty-intel marked this pull request as draft December 2, 2025 18:00
@madhavilosetty-intel
Copy link
Contributor

@kithwa It's a breaking change, so moving to draft state. Please check with Ganesh.

@kithwa kithwa requested a review from graikhel-intel December 3, 2025 00:45
@kithwa
Copy link
Contributor Author

kithwa commented Dec 3, 2025

@kithwa It's a breaking change, so moving to draft state. Please check with Ganesh.

Hi @graikhel-intel
Could you help to review this PR?
Is it to handle MPS issue 1467 (#1467)
Shall we implement this breaking change or we shall not change the response status code?

@kithwa
Copy link
Contributor Author

kithwa commented Dec 8, 2025

@kithwa It's a breaking change, so moving to draft state. Please check with Ganesh.

Hi @graikhel-intel Could you help to review this PR? Is it to handle MPS issue 1467 (#1467) Shall we implement this breaking change or we shall not change the response status code?

Hi all, by the way,
This is CCM with user consent. Probably a manual process which is not automated by customer.
In this sense, it could be a low-risk breaking change.

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.

2 participants