Skip to content

fix(config): day-unit durations + de-dup helpers (#294-298) - #331

Merged
scttfrdmn merged 1 commit into
mainfrom
audit/dups-294-298
Jul 11, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
audit/dups-294-298

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Closes #294, #295, #296, #298. Defers #297 (see below). Part of the audit tracker #328 (Phase 0/1).

#298 — real bug (Fixed)

A local config ttl: 2d (or idle-timeout, completion-delay) was parsed by time.ParseDuration, which rejects the d unit, so config.ParseDuration returned 0 and the setting was silently dropped. This hits pkg/provider/local.go (TTL/IdleTimeout/CompletionDelay).

Fix: config.ParseDuration now delegates to a new day-aware ParseDurationE (native Go syntax first, then <n>{s,m,h,d} segments). The CLI's cmd/state.go:parseDuration — which already had the day-aware logic — now delegates to the same shared parser, so the two paths can't drift again. Regression test added (TestParseDuration, incl. 2d→48h).

De-duplication (Changed, no behavior change)

Deferred

Verification

CHANGELOG updated under Fixed + Changed.

@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 48.64865% with 38 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/utils.go 0.00% 7 Missing ⚠️
pkg/config/local.go 85.36% 4 Missing and 2 partials ⚠️
cmd/autoscale.go 0.00% 3 Missing ⚠️
cmd/alerts.go 0.00% 2 Missing ⚠️
cmd/bot.go 0.00% 2 Missing ⚠️
cmd/cost.go 0.00% 2 Missing ⚠️
cmd/list.go 0.00% 2 Missing ⚠️
cmd/list_amis.go 0.00% 2 Missing ⚠️
cmd/state.go 33.33% 2 Missing ⚠️
cmd/team.go 0.00% 2 Missing ⚠️
... and 8 more

📢 Thoughts on this report? Let us know!

…298)

"2d"/"1d12h" were parsed by time.ParseDuration, which rejects "d", so
the value silently became 0. config.ParseDuration now uses a day-aware
parser (ParseDurationE); the CLI's parseDuration delegates to it, so the
CLI and config paths share one implementation. Regression test added.

Also de-duplicated three helper pairs (no behavior change):
- #294: formatDurationForTTL was byte-identical to formatDuration; deleted
  it and repointed the TTL path + tests to formatDuration.
- #295: truncate == truncateValue; kept one truncate in cmd/utils.go.
- #296: ~20 identical tabwriter.NewWriter(...,2,' ',0) call sites now go
  through newTableWriter(); normalized the one padding-3 outlier (dns.go).

Deferred #297 (per-region EC2 client helper): it spans 40+ pkg/aws sites
on the AWS hot path and the finding rated it optional — better as its own
focused PR than bundled here.
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.

[audit] Dup: formatDuration and formatDurationForTTL are byte-identical — collapse to one

1 participant