web: emit canonical error code alias
Some checks are pending
check / secretapi (push) Waiting to run
Some checks are pending
check / secretapi (push) Waiting to run
This commit is contained in:
parent
687dd5dd3c
commit
cc682e289b
@ -1827,9 +1827,11 @@ func writeErrorCode(w http.ResponseWriter, status int, code string, message stri
|
|||||||
correlationID = "req_" + rid
|
correlationID = "req_" + rid
|
||||||
}
|
}
|
||||||
normalizedCode := strings.TrimSpace(strings.ToLower(code))
|
normalizedCode := strings.TrimSpace(strings.ToLower(code))
|
||||||
|
canonicalCode := canonicalErrorCode(normalizedCode)
|
||||||
writeJSON(w, status, map[string]string{
|
writeJSON(w, status, map[string]string{
|
||||||
"error": message,
|
"error": message,
|
||||||
"code": normalizedCode,
|
"code": normalizedCode,
|
||||||
|
"canonical_code": canonicalCode,
|
||||||
"next_step": errorNextStepForCode(normalizedCode),
|
"next_step": errorNextStepForCode(normalizedCode),
|
||||||
"correlation_id": correlationID,
|
"correlation_id": correlationID,
|
||||||
})
|
})
|
||||||
@ -1867,6 +1869,20 @@ func errorNextStepForCode(code string) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func canonicalErrorCode(code string) string {
|
||||||
|
code = strings.TrimSpace(strings.ToLower(code))
|
||||||
|
switch code {
|
||||||
|
case "membership_inactive":
|
||||||
|
return "edut_id_inactive"
|
||||||
|
case "membership_required":
|
||||||
|
return "edut_id_required"
|
||||||
|
case "membership_verification_failed":
|
||||||
|
return "edut_id_verification_failed"
|
||||||
|
default:
|
||||||
|
return code
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func appendUniqueString(existing []string, value string) []string {
|
func appendUniqueString(existing []string, value string) []string {
|
||||||
value = strings.TrimSpace(value)
|
value = strings.TrimSpace(value)
|
||||||
if value == "" {
|
if value == "" {
|
||||||
|
|||||||
@ -110,6 +110,7 @@ Authorization: Bearer <wallet-session>
|
|||||||
{
|
{
|
||||||
"error": "entitlement_inactive",
|
"error": "entitlement_inactive",
|
||||||
"code": "entitlement_inactive",
|
"code": "entitlement_inactive",
|
||||||
|
"canonical_code": "entitlement_inactive",
|
||||||
"correlation_id": "req_01J9B6BJBVKY3N6WQ7TQM2R2P5"
|
"correlation_id": "req_01J9B6BJBVKY3N6WQ7TQM2R2P5"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@ -107,6 +107,7 @@ Content-Type: application/json
|
|||||||
{
|
{
|
||||||
"error": "membership_inactive",
|
"error": "membership_inactive",
|
||||||
"code": "membership_inactive",
|
"code": "membership_inactive",
|
||||||
|
"canonical_code": "edut_id_inactive",
|
||||||
"correlation_id": "req_01J9A4Q9GPDXDNZEWJ2FJS6F5R"
|
"correlation_id": "req_01J9A4Q9GPDXDNZEWJ2FJS6F5R"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -145,6 +146,7 @@ Content-Type: application/json
|
|||||||
{
|
{
|
||||||
"error": "contact_your_org_admin",
|
"error": "contact_your_org_admin",
|
||||||
"code": "owner_role_required",
|
"code": "owner_role_required",
|
||||||
|
"canonical_code": "owner_role_required",
|
||||||
"correlation_id": "req_01J9A6ZC0SYF5A0M8AP8BNX7B2"
|
"correlation_id": "req_01J9A6ZC0SYF5A0M8AP8BNX7B2"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -155,6 +157,7 @@ Content-Type: application/json
|
|||||||
{
|
{
|
||||||
"error": "owner support actions require onramp_attested identity assurance",
|
"error": "owner support actions require onramp_attested identity assurance",
|
||||||
"code": "identity_assurance_insufficient",
|
"code": "identity_assurance_insufficient",
|
||||||
|
"canonical_code": "identity_assurance_insufficient",
|
||||||
"correlation_id": "req_01J9A72Q2Q0VQ8MCR7D2N95D3R"
|
"correlation_id": "req_01J9A72Q2Q0VQ8MCR7D2N95D3R"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@ -389,6 +389,10 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
code:
|
code:
|
||||||
type: string
|
type: string
|
||||||
|
description: Emitted compatibility code (may be legacy).
|
||||||
|
canonical_code:
|
||||||
|
type: string
|
||||||
|
description: Canonical EDUT ID era code alias for deterministic client routing.
|
||||||
next_step:
|
next_step:
|
||||||
type: string
|
type: string
|
||||||
description: Deterministic operator guidance for remediation/retry.
|
description: Deterministic operator guidance for remediation/retry.
|
||||||
|
|||||||
@ -413,6 +413,10 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
code:
|
code:
|
||||||
type: string
|
type: string
|
||||||
|
description: Emitted compatibility code (may be legacy).
|
||||||
|
canonical_code:
|
||||||
|
type: string
|
||||||
|
description: Canonical EDUT ID era code alias for deterministic client routing.
|
||||||
next_step:
|
next_step:
|
||||||
type: string
|
type: string
|
||||||
description: Deterministic operator guidance for remediation/retry.
|
description: Deterministic operator guidance for remediation/retry.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user