Skip to content

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
merged 8 commits into from
Jun 13, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 5, 2025

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 in resource_billing_policy.go:

  • name attribute
  • location attribute
  • billing_instrument.resource_group attribute
  • billing_instrument.subscription_id attribute

This 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 in internal/customerrors/url_format_error.go to use pointer receivers for better maintainability:

  • Changed interface assertion from var _ error = UrlFormatError{} to var _ error = (*UrlFormatError)(nil)
  • Updated Error() and Unwrap() methods to use pointer receivers (*UrlFormatError)
  • Fixed related test case in client_test.go to check for pointer type

This 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:

  • Changed UUIDTypeErrorInvalidStringDetails from raw string literal with literal \n to regular string literal with proper escape sequences
  • Error messages now display proper line breaks instead of literal \n characters

Before:

A string value was provided that is not valid UUID string format.\n\nGiven Value: invalid-uuid\n

After:

A string value was provided that is not valid UUID string format.

Given Value: invalid-uuid

Testing

  • All changes pass linting with make lint
  • Code builds successfully with make build
  • Documentation generation completes without errors with make userdocs
  • No regressions introduced in existing functionality

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.

Copilot AI and others added 4 commits June 5, 2025 12:29
…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 Copilot AI changed the title [WIP] [Copilot] Type Safety and Formatting Issues Fix type safety and formatting issues in provider code Jun 5, 2025
@Copilot Copilot AI requested a review from mawasile June 5, 2025 12:37
Copilot finished work on behalf of mawasile June 5, 2025 12:37
@mawasile mawasile marked this pull request as ready for review June 5, 2025 13:38
@Copilot Copilot AI review requested due to automatic review settings June 5, 2025 13:38
@mawasile mawasile requested a review from a team as a code owner June 5, 2025 13:38
Copy link
Contributor

@Copilot Copilot AI left a 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 mawasile added 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 labels Jun 9, 2025
@mawasile mawasile merged commit 62a2def into main Jun 13, 2025
11 checks passed
@mawasile mawasile deleted the copilot/fix-825 branch June 13, 2025 19:14
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
Projects
None yet
Development

Error loading sessions

Retrying...

Successfully merging this pull request may close these issues.

[Copilot] Type Safety and Formatting Issues
4 participants