fix: userConsent req to return specific http sts codes#2224
fix: userConsent req to return specific http sts codes#2224
Conversation
There was a problem hiding this comment.
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.tsmodule with functions to map AMT return values to HTTP status codes and generate detailed error messages - Updated
send.ts,request.ts, andcancel.tsto 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>
|
@kithwa It's a breaking change, so moving to draft state. Please check with Ganesh. |
Hi @graikhel-intel |
Hi all, by the way, |
PR Checklist
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 )