fix: handle DataValidationError raised by check_services_unique validator#500
Merged
Thanhphan1147 merged 3 commits intomainfrom Apr 30, 2026
Merged
fix: handle DataValidationError raised by check_services_unique validator#500Thanhphan1147 merged 3 commits intomainfrom
Thanhphan1147 merged 3 commits intomainfrom
Conversation
…eRequirersData Change check_services_unique validator to add duplicate-service relation IDs to relation_ids_with_invalid_data instead of raising DataValidationError, following the same pattern as check_external_grpc_port_unique and the TCP library's check_ports_unique. Agent-Logs-Url: https://github.com/canonical/haproxy-operator/sessions/fea73f9b-589e-4ff6-b73d-0768d1cbb90d Co-authored-by: Thanhphan1147 <42444001+Thanhphan1147@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix DataValidationError handling in get_data method
fix: handle DataValidationError raised by check_services_unique validator
Apr 29, 2026
swetha1654
reviewed
Apr 30, 2026
f-atwi
approved these changes
Apr 30, 2026
Contributor
Test results for commit f43e3b7Test coverage for f43e3b7 Static code analysis report |
Contributor
Test results for commit f43e3b7Test coverage for f43e3b7 Static code analysis report |
Contributor
Test results for commit f43e3b7Test coverage for f43e3b7 Static code analysis report |
Contributor
Test results for commit f43e3b7Test coverage for f43e3b7 Static code analysis report |
Contributor
Test results for commit f43e3b7Test coverage for f43e3b7 Static code analysis report |
seb4stien
approved these changes
Apr 30, 2026
Thanhphan1147
added a commit
that referenced
this pull request
May 4, 2026
- .github/skills/pr-best-practices/SKILL.md: skill that analyzes merged LLM-authored PRs, compares first vs final commit, and synthesizes do/don't rules with concrete code examples into best-practices.instructions.md - .github/skills/pr-best-practices/evals/evals.json: 3 eval cases covering substantive PR, validation-fix PR, and trivial (non-significant) PR - .github/instructions/best-practices.instructions.md: initial rules extracted from PR #475 (relation contracts, reconcile flow, testing) and PR #500 (validation error handling) with before/after code examples - .gitignore: ignore *-workspace/ directories (skill eval scratch data) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Thanhphan1147
added a commit
that referenced
this pull request
May 4, 2026
- .github/skills/pr-best-practices/SKILL.md: skill that analyzes merged LLM-authored PRs, compares first vs final commit, and synthesizes do/don't rules with concrete code examples into best-practices.instructions.md - .github/skills/pr-best-practices/evals/evals.json: 3 eval cases covering substantive PR, validation-fix PR, and trivial (non-significant) PR - .github/instructions/best-practices.instructions.md: initial rules extracted from PR #475 (relation contracts, reconcile flow, testing) and PR #500 (validation error handling) with before/after code examples - .gitignore: ignore *-workspace/ directories (skill eval scratch data) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
What this PR does
Changes
check_services_uniqueinHaproxyRouteRequirersDatato add duplicate-service relation IDs torelation_ids_with_invalid_datainstead of raisingDataValidationError. This follows the existing pattern used bycheck_external_grpc_port_uniqueand the TCP library'scheck_ports_unique.lib/charms/haproxy/v2/haproxy_route.py): Replaced the raise with tracking duplicate service relation IDs, using the samedefaultdictapproach as the gRPC port validator.test_check_services_uniquecovering mixed duplicate/unique services.Why we need it
The
_configurehandler callsget_data(relations)which constructsHaproxyRouteRequirersData. Thecheck_services_uniquemodel validator raisesDataValidationErroron duplicate services, but this exception is unhandled — it propagates out of_configureand crashes the charm. The correct behavior is to mark offending relations as invalid and continue, which is what the other validators already do.Test plan
All 251 unit tests pass. The new test validates that duplicate-service relations get their IDs added to
relation_ids_with_invalid_datawhile unique services remain unaffected.Review focus
The validator now silently discards all relations with duplicate service names (both/all duplicates, not just the second one). This matches the TCP
check_ports_uniquebehavior.Checklist
docs/changelog.mdwith user-relevant changesdocs/release-notes/artifacts. If no change artifact is necessary, I tagged the PR with the labelno-release-note.(e.g., in
.github/workflows/integration_tests.yaml, ensure themoduleslist is correct)terraform fmtpasses andtflintreports no errorsWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
gitlab.com/usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either: