-
Notifications
You must be signed in to change notification settings - Fork 15
Fix type safety and formatting issues in provider code #844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
…fields Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
…-proofing Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
Copilot finished work on behalf of
mawasile
June 5, 2025 12:37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves type safety and formatting in provider-related code to enhance reliability and user experience.
- Added string validation for required attributes in the billing policy resource.
- Updated error type assertions and pointer receiver usage for URL format errors.
- Corrected newline formatting in UUID error messages and updated corresponding tests.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
internal/services/licensing/resource_billing_policy.go | Added string validators for required fields to prevent empty inputs. |
internal/customtypes/uuid_value.go | Changed UUID error message literal to enable proper newline formatting. |
internal/customerrors/url_format_error.go | Updated error type assertion and methods to use pointer receivers. |
internal/api/client_test.go | Modified test case for error type to align with pointer receiver implementation. |
.changes/unreleased/fixed_type_safety_formatting_issues.yaml | Documented the fixed type safety and formatting issues. |
mawasile
approved these changes
Jun 9, 2025
mattdot
approved these changes
Jun 12, 2025
eduardodfmex
approved these changes
Jun 13, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
ai assisted
Pull requests that have be fully or partially implemented using Copilot or AI
ai found
Issues and Bugs that were found using AI
copilot
fixed using GitHub copilot autonomous agent
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.
This PR addresses three type safety and formatting issues identified in the codebase to improve code reliability and user experience.
Changes Made
Issue 1: Missing String Validation in Billing Policy Resource
Added
stringvalidator.LengthAtLeast(1)
validation to required string attributes inresource_billing_policy.go
:name
attributelocation
attributebilling_instrument.resource_group
attributebilling_instrument.subscription_id
attributeThis prevents empty strings from being passed to the API, which could cause confusing errors for users.
Issue 2: Interface Implementation Assertion in UrlFormatError
Updated
UrlFormatError
ininternal/customerrors/url_format_error.go
to use pointer receivers for better maintainability:var _ error = UrlFormatError{}
tovar _ error = (*UrlFormatError)(nil)
Error()
andUnwrap()
methods to use pointer receivers (*UrlFormatError
)client_test.go
to check for pointer typeThis follows Go best practices and ensures future-proofing if the error type needs to be extended.
Issue 3: Escaped Newlines in UUID Error Messages
Fixed newline formatting in
internal/customtypes/uuid_value.go
:UUIDTypeErrorInvalidStringDetails
from raw string literal with literal\n
to regular string literal with proper escape sequences\n
charactersBefore:
After:
Testing
make lint
make build
make userdocs
Fixes #825.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.