Skip to content

fix(web): reject invalid dashboard periods without exiting - #554

Merged
iamtoruk merged 2 commits into
getagentseal:mainfrom
ozymandiashh:fix/web-period-validation
Jun 28, 2026
Merged

iamtoruk merged 2 commits into
getagentseal:mainfrom
ozymandiashh:fix/web-period-validation

Conversation

@ozymandiashh

Copy link
Copy Markdown
Collaborator

Follow-up from the dashboard/devices release check.

A bad period query should not be able to terminate a long-running web/share server. The CLI should still fail loudly for invalid --period, but HTTP handlers need to return an error response and keep serving.

What changed:

  • Added a non-exiting period parser for server paths.
  • /api/usage and /api/devices now return JSON 400 for invalid period/date query params instead of exiting the process.
  • The share server maps invalid usage-query inputs to HTTP 400 instead of treating them as internal errors.
  • CLI behavior remains unchanged: invalid --period still prints the error and exits non-zero.

Validation:

  • npm test -- tests/cli-date.test.ts tests/dashboard.test.ts tests/sharing --run — 57 passing
  • npx tsc --noEmit
  • npm run build
  • Manual Chrome check across Today / 7 days / 30 days / Month / All: each period reached the expected label with no stuck Loading state.
  • Manual API check: invalid /api/usage and /api/devices periods returned 400 JSON; /api/identity still returned 200 afterwards.

@ozymandiashh
ozymandiashh force-pushed the fix/web-period-validation branch from 4b39fcd to 537b1a4 Compare June 22, 2026 03:26
@ozymandiashh

Copy link
Copy Markdown
Collaborator Author

Updated and re-verified after rebasing on current main.

Final validation:

  • npm test -- tests/cli-date.test.ts tests/sharing/transport.test.ts --run — 26 tests passed
  • npx tsc --noEmit — passed
  • npm run build — passed (CLI + dashboard)
  • manual Chrome dashboard QA after the final build:
    • /api/usage?period=not-a-period returns 400
    • /api/devices?period=not-a-period returns 400
    • server remains alive after invalid input (/api/usage?period=today returns 200)
    • Month / Today / 7 days / 30 days / All all load to their expected period labels without staying in Loading
    • observed final-load timings on my large local dataset: Month ~0.5s, Today ~3.5s, 7 days ~7.1s, 30 days ~9.1s, All ~10.1s

I also checked the dashboard visually with screenshots for each period after the rebase. I do not have a second Mac available, so I could not physically validate mDNS discovery between two machines; local pairing/transport/API behavior was exercised.

PR is mergeable and current checks are green.

…dundant /api/devices re-parse

- Add tests/web-dashboard.test.ts: boots the dashboard on an ephemeral port and asserts
  /api/usage and /api/devices answer 400 (not process.exit) for a bad period, and that
  the server keeps serving afterward. runWebDashboard now returns the http.Server so it
  can be exercised in-process; callers that ignore the return value are unaffected.
- /api/devices: resolve periodInfo once instead of validating then re-parsing it inside
  localGetUsage (pullDevices invokes localGetUsage with the same already-validated query).
@iamtoruk
iamtoruk merged commit 7cd1f90 into getagentseal:main Jun 28, 2026
3 checks passed
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.

2 participants