Skip to content

config: eliminate duplicate body between UnsupportedField and InvalidValue#8097

Open
Copilot wants to merge 3 commits into
mainfrom
copilot/duplicate-code-remove-unsupportedfield
Open

config: eliminate duplicate body between UnsupportedField and InvalidValue#8097
Copilot wants to merge 3 commits into
mainfrom
copilot/duplicate-code-remove-unsupportedfield

Conversation

Copilot AI commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

UnsupportedField and InvalidValue in internal/config/validation_errors.go had byte-for-byte identical bodies — any future change to ValidationError construction (e.g. adding a Code field) would need to be applied twice.

Changes

  • internal/config/validation_errors.go: UnsupportedField is now a documented alias that delegates to InvalidValue, removing the duplicate struct literal while preserving both names (both have active call sites in validation.go)
// Before: UnsupportedField had its own identical struct literal
func UnsupportedField(fieldName, message, jsonPath, suggestion string) *ValidationError {
    return &ValidationError{Field: fieldName, Message: message, JSONPath: jsonPath, Suggestion: suggestion}
}

// After: delegates to InvalidValue
func UnsupportedField(fieldName, message, jsonPath, suggestion string) *ValidationError {
    return InvalidValue(fieldName, message, jsonPath, suggestion)
}

No call sites changed — both function names are retained for semantic clarity (UnsupportedField = structural/unrecognized field; InvalidValue = constraint violation).

GitHub Advanced Security started work on behalf of lpcox June 25, 2026 16:15 View session
GitHub Advanced Security finished work on behalf of lpcox June 25, 2026 16:16
GitHub Advanced Security started work on behalf of lpcox June 25, 2026 16:19 View session
Copilot AI changed the title [WIP] Remove duplicate factory function UnsupportedField config: eliminate duplicate body between UnsupportedField and InvalidValue Jun 25, 2026
GitHub Advanced Security finished work on behalf of lpcox June 25, 2026 16:20
Copilot AI requested a review from lpcox June 25, 2026 16:20
Copilot finished work on behalf of lpcox June 25, 2026 16:20
@lpcox lpcox marked this pull request as ready for review June 25, 2026 16:54
Copilot AI review requested due to automatic review settings June 25, 2026 16:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 removes duplicated ValidationError construction logic by making UnsupportedField a documented alias that delegates to InvalidValue, keeping both names available for clearer call-site semantics while ensuring future changes to ValidationError only need to be made once.

Changes:

  • Refactored UnsupportedField to call InvalidValue(...) instead of duplicating the struct literal.
  • Added doc comments clarifying UnsupportedField as an alias retained for semantic clarity.
Show a summary per file
File Description
internal/config/validation_errors.go Deduplicates ValidationError construction by delegating UnsupportedField to InvalidValue and documents the alias intent.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@lpcox

lpcox commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts in this pull request

…e-remove-unsupportedfield

# Conflicts:
#	internal/config/validation_errors.go

Copilot AI commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Resolved. The only conflict was in the doc comment for UnsupportedField — both sides had made the same functional change (delegating to InvalidValue) but with slightly different wording. Merged with origin/main in 7da6d07, keeping the main-branch doc comment. All checks pass.

Copilot finished work on behalf of lpcox June 25, 2026 17:17
GitHub Advanced Security started work on behalf of lpcox June 25, 2026 17:17 View session
GitHub Advanced Security finished work on behalf of lpcox June 25, 2026 17:18
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.

3 participants