Skip to content

fix: include HTTP status code in error messages to prevent empty diagnostics - #185

Open
arslanbekov wants to merge 1 commit into
datadrivers:mainfrom
arslanbekov:fix/empty-error-messages
Open

fix: include HTTP status code in error messages to prevent empty diagnostics#185
arslanbekov wants to merge 1 commit into
datadrivers:mainfrom
arslanbekov:fix/empty-error-messages

Conversation

@arslanbekov

Copy link
Copy Markdown

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:

return nil, fmt.Errorf("%s", string(body))  // body is empty → error message is ""

This causes Terraform to display the unhelpful diagnostic:

Error: Empty Summary: This is always a bug in the provider and should be reported to the provider developers.

Instead of a clear message like:

Error: could not get role 'developer': HTTP 401,

Changes

Updated all 26 occurrences of fmt.Errorf("%s", string(body)) across 6 files to include:

  • HTTP status code
  • Resource type and identifier (where available)
  • Descriptive action context (get/create/update/delete)

Files changed:

  • nexus3/pkg/security/role.go — role CRUD operations
  • nexus3/pkg/security/user.go — user CRUD operations
  • nexus3/pkg/security/privilege/service.go — privilege delete
  • nexus3/routing_rule.go — routing rule CRUD operations
  • nexus3/mail_config.go — mail config CRUD operations
  • nexus3/script.go — script CRUD operations

This follows the pattern already established in privilege/service.go List and Get functions, which correctly include HTTP status codes.

Related issues

…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
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.

Import fails for nexus_security_role with "Empty Summary" error

1 participant