Skip to content

fix: type safety overhaul, bug fixes, and hardening#3

Closed
caballeto wants to merge 1 commit intomainfrom
fix/type-safety-and-bugs
Closed

fix: type safety overhaul, bug fixes, and hardening#3
caballeto wants to merge 1 commit intomainfrom
fix/type-safety-and-bugs

Conversation

@caballeto
Copy link
Copy Markdown
Contributor

Summary

  • Eliminate all as any from standalone commands (20 files). Only the CRUD factory (crud-commands.ts) retains 5 intentional casts for dynamic path construction, documented.
  • Fix 15 bugs including notification policy update corruption, unhandled JSON.parse, corrupt context crash, default org ID '1', wrong field names in monitors/results and data/services, etc.
  • Harden security: validate tokens on context create, restrict file permissions (0o600), remove silent fallbacks.
  • Wire up error handling: handleApiError now routes through checkedFetch for proper AuthError/DevhelmError exit codes.
  • Fix spec-check CI: add JSON validation, include descriptions.generated.ts in auto-PR.

Test plan

  • npm run build — clean
  • npm run lint — 0 errors (1 pre-existing warning in output.ts)
  • npm test — 2/2 pass
  • npx tsc --noEmit — clean
  • Surface integration tests (triggered by monorepo PR)
  • Manual verification: devhelm auth login, devhelm monitors list, devhelm status

Made with Cursor

Type safety:
- Regenerate api.generated.ts from latest spec (actor param removed, /auth/me added)
- Remove all `as any` from standalone commands — full typed paths and responses
- Confine remaining `as any` to CRUD factory (crud-commands.ts) with documented rationale

Bug fixes:
- Notification policy update: only send explicitly passed fields (was sending "undefined")
- Alert channel --config: wrap JSON.parse in try/catch with user-friendly error
- Corrupt contexts.json: graceful fallback instead of crash
- Remove default org/workspace ID '1' fallback — only send when explicitly set
- Wire up handleApiError for structured AuthError/DevhelmError with proper exit codes
- Add MCP_SERVER to validate.ts VALID_TYPES
- Fix monitors/results field names to match DTO (responseTimeMs, timestamp, passed)
- Fix data/services path param {slug} → {slugOrId}
- Fix api-keys/revoke path param type (string → number)

Hardening:
- auth context create: validate token before saving (--skip-validation to bypass)
- File permissions: contexts.json 0o600, .devhelm/ dir 0o700
- Init template: interval → frequency to match CLI flags
- Fix environment color flag description (was pulling from wrong schema)
- Consistent token prefix examples (dh_live_...)
- data/services/uptime: period and granularity options match spec enums

CI:
- spec-check.yml: add JSON validation step, include descriptions.generated.ts in auto-PR

Made-with: Cursor
@caballeto caballeto closed this Apr 11, 2026
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.

1 participant