Skip to content

fix(overrides): address gaps in attribute override system (#345)#346

Merged
Starosdev merged 3 commits intodevelopfrom
fix/SCR-345-attribute-override-gaps
Mar 11, 2026
Merged

fix(overrides): address gaps in attribute override system (#345)#346
Starosdev merged 3 commits intodevelopfrom
fix/SCR-345-attribute-override-gaps

Conversation

@Starosdev
Copy link
Owner

Summary

  • Add DB migration (m20260411000000) to enforce a unique constraint on (protocol, attribute_id, wwn) in attribute_overrides, deduplicating any existing rows first
  • Update AttributeOverride model GORM tags to use uniqueIndex to match the new constraint
  • Add GetAllOverridesForDisplay repository method that merges UI overrides (DB) with config-file overrides, so the settings panel shows everything currently active — config overrides appear as read-only (source: config, ID: 0)
  • Add corresponding mock method for GetAllOverridesForDisplay
  • Refactor SaveAttributeOverride to extract validation helpers (validateAttributeOverride, validateForceStatus, validateThresholds) to keep cognitive complexity in bounds
  • Add input validation: at least one threshold required in custom mode, warn_above < fail_above, non-negative values, and WWN hex-format check for all action types
  • Fix misleading comment in applier.go that implied thresholds can be combined with force_status — they are mutually exclusive at the call site
  • Default new override form action to custom threshold (empty string) so threshold fields are visible on first open instead of ignore
  • Add 18 handler unit tests for GetAttributeOverrides and SaveAttributeOverride (mock-based, no InfluxDB required)

Linked Issues

Closes #345

Test plan

  • go build ./... passes cleanly
  • All 18 new handler tests pass (go test -v -run TestAttributeOverride ./webapp/backend/pkg/web/handler/...)
  • All overrides package unit tests pass (go test -v ./webapp/backend/pkg/overrides/...)
  • Migration ordering verified (m20260410 before m20260411 in slice)
  • WWN validation tested for all three action types
  • Threshold edge cases verified (warn >= fail correctly rejected)

- Add migration m20260411000000 to enforce unique constraint on
  (protocol, attribute_id, wwn) in attribute_overrides, deduplicating
  any existing rows before creating the index
- Update AttributeOverride model to use uniqueIndex tag to match
- Add GetAllOverridesForDisplay repo method and mock; GET
  /api/settings/overrides now returns both UI and config file overrides
  so users can see everything active in the settings panel
- Extract validation from SaveAttributeOverride into helpers to keep
  cognitive complexity within limits; add validation for: at least one
  threshold required in custom mode, warn_above < fail_above, non-negative
  thresholds, and WWN format
- Fix misleading comment in applier.go that implied thresholds can be
  combined with force_status; they are mutually exclusive at the call site
- Default new override form action to custom threshold so warn/fail
  fields are visible without requiring an extra dropdown interaction
- Add 18 handler unit tests covering GET, POST validation paths, and DELETE
Ensure m20260410000000 (notify_on_collector_error setting) appears
before m20260411000000 (attribute_overrides unique index) in the
migrations slice, matching chronological order.
@Starosdev Starosdev added bug Something isn't working backend Backend/Go related frontend Frontend/Angular related labels Mar 11, 2026
@Starosdev Starosdev linked an issue Mar 11, 2026 that may be closed by this pull request
7 tasks
@Starosdev Starosdev merged commit 6e3e489 into develop Mar 11, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend/Go related bug Something isn't working frontend Frontend/Angular related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(overrides): address gaps in attribute override system

1 participant