Skip to content

fix: include error detail in GenericOpenAPIError.Error() - #585

Open
exitcode0 wants to merge 2 commits into
okta:masterfrom
exitcode0:fix/generic-openapi-error-detail
Open

fix: include error detail in GenericOpenAPIError.Error()#585
exitcode0 wants to merge 2 commits into
okta:masterfrom
exitcode0:fix/generic-openapi-error-detail

Conversation

@exitcode0

Copy link
Copy Markdown
Contributor

Summary

  • GenericOpenAPIError.Error() now surfaces the Okta error summary, error code, error ID, and error causes instead of returning only the HTTP status text
  • Updated both the generator template and the generated okta/client.go

Motivation

When an Okta API call fails, GenericOpenAPIError.Error() only returns a generic message like "the server responded with status 400". The structured error detail from the response body (error summary, code, causes) is available via GenericOpenAPIError.Model() but isn't included in the error string, making debugging difficult without explicit type assertions.

Example output

the server responded with status 400: Login failed (errorCode: E0000004, errorId: oae123abc). Causes: Invalid password

Test plan

  • Verify GenericOpenAPIError.Error() returns enriched message when model is *Error
  • Verify fallback to original e.error when model is nil or a different type
  • Verify partial error fields (e.g. no causes, no error code) produce clean output

When a GenericOpenAPIError contains an unpacked Error model, the Error()
method now returns the error summary and any error causes instead of
just the HTTP status text. This provides much more actionable error
messages to API consumers.
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