Skip to content

Conversation

@kithwa
Copy link

@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 401 (Unauthorized)
      • 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.

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.

1 participant