6.8 KiB
post_title, categories, tags, summary, post_date
| post_title | categories | tags | summary | post_date | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Current Spec: Resolve Proxy Host Hostname Validation Test Failures |
|
|
Focused plan to resolve failing TestProxyHostService_ValidateHostname malformed URL cases by aligning test expectations with intended validation behavior and validating via targeted service tests and coverage gate. | 2026-02-22 |
Active Plan: Resolve Failing Hostname Validation Tests
Date: 2026-02-22 Status: Active and authoritative Scope Type: Backend test-failure remediation (service validation drift analysis) Authority: This is the only active authoritative plan section in this file.
Introduction
This plan resolves backend run failures in TestProxyHostService_ValidateHostname
for malformed URL cases while preserving intended hostname validation behavior.
Primary objective:
- Restore green test execution in
backend/internal/serviceswith a minimal, low-risk change path.
Research Findings
Evidence Collected
- Failing command output confirms two failing subtests:
TestProxyHostService_ValidateHostname/malformed_https_URLTestProxyHostService_ValidateHostname/malformed_http_URL
- Failure message for both cases:
invalid hostname format.
Exact Files Involved
backend/internal/services/proxyhost_service_validation_test.go- Test function:
TestProxyHostService_ValidateHostname - Failing cases currently expect
wantErr: falsefor malformed URLs.
- Test function:
backend/internal/services/proxyhost_service.go- Service function:
ValidateHostname(host string) error - Behavior: strips scheme, then validates hostname characters; malformed
residual values containing
:are rejected withinvalid hostname format.
- Service function:
Root Cause Determination
- Root cause is test expectation drift, not runtime service regression.
git blameshows malformed URL test cases were added on 2026-02-22 with permissive expectations, while validation behavior rejecting malformed host strings predates those additions.- Existing behavior aligns with stricter hostname validation and should remain the default unless product requirements explicitly demand permissive handling of malformed host inputs.
Confidence Assessment
- Confidence score: 95% (High)
- Rationale: direct reproduction, targeted file inspection, and blame history converge on expectation drift.
Requirements (EARS)
- WHEN malformed
http://orhttps://host strings are passed toValidateHostname, THE SYSTEM SHALL return a validation error. - WHEN service validation behavior is intentionally strict, THE TESTS SHALL assert rejection for malformed URL residual host strings.
- IF product intent is permissive for malformed inputs, THEN THE SYSTEM SHALL minimally relax parsing logic without weakening valid invalid-character checks.
- WHEN changes are completed, THE SYSTEM SHALL pass targeted service tests and the backend coverage gate script.
Technical Specification
Minimal Fix Path (Preferred)
Preferred path: test-only correction.
- Update malformed URL table entries in
backend/internal/services/proxyhost_service_validation_test.go:malformed https URL->wantErr: truemalformed http URL->wantErr: true
- Keep current service behavior in
backend/internal/services/proxyhost_service.gounchanged. - Optional test hardening (still test-only): assert error contains
invalid hostname formatfor those two cases.
Alternative Path (Only if Product Intent Differs)
Use only if maintainers explicitly confirm malformed URL inputs should pass:
- Apply minimal service correction in
ValidateHostnameto normalize malformed scheme inputs before character validation. - Add or update tests to preserve strict rejection for truly invalid hostnames
(e.g.,
$,@,%,&) so validation is not broadly weakened.
Decision default for this plan: Preferred path (test updates only).
Implementation Plan
Phase 1: Test-first Repro and Baseline
- Confirm current failure (already reproduced).
- Record failing subtests and error signatures as baseline evidence.
Phase 2: Minimal Remediation
- Apply preferred test expectation update in
backend/internal/services/proxyhost_service_validation_test.go. - Keep service code unchanged unless product intent is clarified otherwise.
Phase 3: Targeted Validation
Run in this order:
go test ./backend/internal/services -run TestProxyHostService_ValidateHostname -v- Related service package tests:
go test ./backend/internal/services -run TestProxyHostService -vgo test ./backend/internal/services -v
- Final gate:
bash scripts/go-test-coverage.sh
Risk Assessment
Key Risks
- Semantic risk (low): updating tests could mask an intended behavior change if malformed URL permissiveness was deliberate.
- Coverage risk (low): test expectation changes may alter branch coverage marginally but should not threaten gate based on current context.
- Regression risk (low): service runtime behavior remains unchanged in the preferred path.
Mitigations
- Keep change surgical to two table entries.
- Preserve existing invalid-character rejection coverage.
- Require full service package run plus coverage script before merge.
Rollback Plan
If maintainer/product decision confirms permissive malformed URL handling is required:
- Revert the test expectation update commit.
- Implement minimal service normalization change in
backend/internal/services/proxyhost_service.go. - Add explicit tests documenting the accepted malformed-input behavior and retain strict negative tests for illegal hostname characters.
- Re-run targeted validation commands and coverage gate.
PR Slicing Strategy
Decision: Single PR.
Rationale:
- Scope is tightly bounded to one service test suite and one failure cluster.
- Preferred remediation is test-only with low rollback complexity.
- Review surface is small and dependency-free.
Contingency split trigger:
- Only split if product intent forces service logic change, in which case:
- PR-1: test expectation alignment rollback + service behavior decision record
- PR-2: minimal service correction + adjusted tests
Config/Infra File Impact Review
Reviewed for required updates:
.gitignore.dockerignorecodecov.ymlDockerfile
Planned changes: None required for this focused backend test-remediation scope.
Acceptance Criteria
TestProxyHostService_ValidateHostnamepasses, including malformed URL subtests.go test ./backend/internal/services -run TestProxyHostService -vpasses.go test ./backend/internal/services -vpasses.bash scripts/go-test-coverage.shpasses final gate.- Root cause is documented as expectation drift vs. service behavior drift, and chosen path is explicitly recorded.