You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Part of duplicate code analysis: #aw_parent_dup001
Summary
TimeoutPositive (line 39) and PositiveInteger (line 52) in internal/config/validation_rules.go both validate that an integer is >= 1 by delegating to TimeoutMinimum. They share identical structure: call TimeoutMinimum with min=1, then post-process the error. TimeoutPositive only overrides Suggestion; PositiveInteger overrides both Message and Suggestion. Both functions serve the same domain — "value must be at least 1" — but use different semantic framing ("timeout" vs "positive integer").
Duplication Details
Pattern: Redundant minimum-value wrappers over TimeoutMinimum
// Lines 39-46funcTimeoutPositive(timeoutint, fieldName, jsonPathstring) *ValidationError {
iferr:=TimeoutMinimum(timeout, 1, fieldName, jsonPath); err!=nil {
err.Suggestion="Use a positive number of seconds (e.g., 30)"returnerr
}
returnnil
}
// Lines 52-63funcPositiveInteger(valueint, fieldName, jsonPathstring) *ValidationError {
logValidation.Printf("Validating positive integer: field=%s, value=%d, jsonPath=%s", fieldName, value, jsonPath)
iferr:=TimeoutMinimum(value, 1, fieldName, jsonPath); err!=nil {
logValidation.Printf("Positive integer validation failed: %s=%d is not positive", fieldName, value)
err.Message=fmt.Sprintf("%s must be a positive integer (>= 1), got %d", fieldName, value)
err.Suggestion=fmt.Sprintf("Use a positive integer (>= 1) for %s", fieldName)
returnerr
}
returnnil
}
Both functions are thin wrappers over TimeoutMinimum(v, 1, ...). The differences are: (a) PositiveInteger has debug log calls; (b) PositiveInteger also overrides Message while TimeoutPositive only overrides Suggestion; (c) the suggestion wording is domain-specific ("seconds" vs "integer").
Impact Analysis
Maintainability: Low risk today since TimeoutMinimum centralises the core logic. Risk increases if either wrapper grows (e.g., adding more overrides or log calls).
Bug Risk: Very low — both wrappers are simple and tested.
Code Bloat: Minor (~12 lines), but the domain separation ("timeout" vs "non-timeout integer") may justify keeping separate named functions with minimal bodies.
Refactoring Recommendations
Have TimeoutPositive delegate to PositiveInteger with a fixed suggestion override (lowest risk, adds consistency):
funcTimeoutPositive(timeoutint, fieldName, jsonPathstring) *ValidationError {
iferr:=PositiveInteger(timeout, fieldName, jsonPath); err!=nil {
err.Suggestion="Use a positive number of seconds (e.g., 30)"returnerr
}
returnnil
}
This ensures TimeoutPositive also gets the improved Message text from PositiveInteger while keeping the timeout-specific suggestion.
Add missing log calls to TimeoutPositive (if delegation is not chosen): add logValidation.Printf calls to TimeoutPositive to match PositiveInteger for observability consistency.
Implementation Checklist
Review duplication findings
Decide: delegate TimeoutPositive to PositiveInteger, or add missing log calls
Implement change in internal/config/validation_rules.go
Run make test to verify no tests break
Parent Issue
See parent analysis report: #aw_parent_dup001
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
awmgmcpg
To allow these domains, add them to the network.allowed list in your workflow frontmatter:
Part of duplicate code analysis: #aw_parent_dup001
Summary
TimeoutPositive(line 39) andPositiveInteger(line 52) ininternal/config/validation_rules.goboth validate that an integer is >= 1 by delegating toTimeoutMinimum. They share identical structure: callTimeoutMinimumwithmin=1, then post-process the error.TimeoutPositiveonly overridesSuggestion;PositiveIntegeroverrides bothMessageandSuggestion. Both functions serve the same domain — "value must be at least 1" — but use different semantic framing ("timeout" vs "positive integer").Duplication Details
Pattern: Redundant minimum-value wrappers over TimeoutMinimum
internal/config/validation_rules.golines 39–46 (TimeoutPositive)internal/config/validation_rules.golines 52–63 (PositiveInteger)Code Sample:
Both functions are thin wrappers over
TimeoutMinimum(v, 1, ...). The differences are: (a)PositiveIntegerhas debug log calls; (b)PositiveIntegeralso overridesMessagewhileTimeoutPositiveonly overridesSuggestion; (c) the suggestion wording is domain-specific ("seconds" vs "integer").Impact Analysis
TimeoutMinimumcentralises the core logic. Risk increases if either wrapper grows (e.g., adding more overrides or log calls).Refactoring Recommendations
Have
TimeoutPositivedelegate toPositiveIntegerwith a fixed suggestion override (lowest risk, adds consistency):This ensures
TimeoutPositivealso gets the improvedMessagetext fromPositiveIntegerwhile keeping the timeout-specific suggestion.Add missing log calls to
TimeoutPositive(if delegation is not chosen): addlogValidation.Printfcalls toTimeoutPositiveto matchPositiveIntegerfor observability consistency.Implementation Checklist
TimeoutPositivetoPositiveInteger, or add missing log callsinternal/config/validation_rules.gomake testto verify no tests breakParent Issue
See parent analysis report: #aw_parent_dup001
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
awmgmcpgSee Network Configuration for more information.