fix: include HTTP status code in error messages to prevent empty diagnostics - #185
Open
arslanbekov wants to merge 1 commit into
Open
fix: include HTTP status code in error messages to prevent empty diagnostics#185arslanbekov wants to merge 1 commit into
arslanbekov wants to merge 1 commit into
Conversation
…nostics
When Nexus returns a non-200 response with an empty body (e.g. 401/403),
fmt.Errorf("%s", string(body)) produces an error with an empty message.
This causes Terraform to display the unhelpful "Empty Summary: This is
always a bug in the provider" diagnostic instead of the actual HTTP error.
This change updates all error formatting to include the HTTP status code
and resource context, matching the pattern already used in privilege and
content_selector services.
Fixes datadrivers/terraform-provider-nexus#555
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When Nexus returns a non-200 HTTP response with an empty body (which happens on 401 Unauthorized and 403 Forbidden), the current error handling produces an error with an empty message:
This causes Terraform to display the unhelpful diagnostic:
Instead of a clear message like:
Changes
Updated all 26 occurrences of
fmt.Errorf("%s", string(body))across 6 files to include:Files changed:
nexus3/pkg/security/role.go— role CRUD operationsnexus3/pkg/security/user.go— user CRUD operationsnexus3/pkg/security/privilege/service.go— privilege deletenexus3/routing_rule.go— routing rule CRUD operationsnexus3/mail_config.go— mail config CRUD operationsnexus3/script.go— script CRUD operationsThis follows the pattern already established in
privilege/service.goList and Get functions, which correctly include HTTP status codes.Related issues