You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.
Overview of the Issue
The APIs for both /plan and /apply return an error status code but do not properly json.Unmarshal the ProjectResult.error into a string. This makes determining what went wrong through the API impossible.
Reproduction Steps
Set up an API key.
Send a request to plan a project that fails because of a terraform issue.
Get a 500 but no useful error/TF output:
Example response:
Not that err from the a.apiPlan will only populate from hooks, the actual plan errors are captured in the result, and detected by the HasErrors() call.
The most friendly fix would probably be something like a custom Unmarshal on the ProjectResults that converts the error to a string
I do not frequently write Golang and am just an Atlantis user, but I could attempt a fix if there is nobody more experienced available to jump on this.
The text was updated successfully, but these errors were encountered:
@johnvandeweghe Hello there! I'm here to help you with any bugs, questions, or contributions. Let's tackle this together!
To address the issue of nested error messages not being properly unmarshalled and displayed in the Atlantis API controller, you can modify the error handling logic to ensure that errors within ProjectResults are correctly extracted and formatted. Here's a suggested approach:
Update the apiReportError Function: Modify this function to handle nested error messages from ProjectResults. This involves checking if the error is of type *command.Result and then extracting the error messages from each ProjectResult.
Modify the Plan and Apply Methods: Ensure these methods use the updated error reporting logic to handle errors from the ProjectResults.
This code ensures that nested errors are properly extracted and included in the API response, making it easier to diagnose issues when Terraform plans or applies fail [1].
Community Note
Overview of the Issue
The APIs for both
/plan
and/apply
return an error status code but do not properlyjson.Unmarshal
theProjectResult.error
into a string. This makes determining what went wrong through the API impossible.Reproduction Steps
Example response:
Note the
ProjectResults[].Error
being a marshalled empty struct instead of the error string.Environment details
This applies to the latest version of atlantis (and likely all previous versions since the API endpoints were added) with the default configuration.
Additional Context
This comes from this snippet (this one is from
/plan
, but/apply
is very similar and has the same problem):Not that
err
from thea.apiPlan
will only populate from hooks, the actual plan errors are captured in the result, and detected by theHasErrors()
call.The most friendly fix would probably be something like a custom
Unmarshal
on theProjectResults
that converts the error to a stringI do not frequently write Golang and am just an Atlantis user, but I could attempt a fix if there is nobody more experienced available to jump on this.
The text was updated successfully, but these errors were encountered: