fix: product readiness — security, performance, observability, UX#8
Open
rcasto123 wants to merge 9 commits into
Open
fix: product readiness — security, performance, observability, UX#8rcasto123 wants to merge 9 commits into
rcasto123 wants to merge 9 commits into
Conversation
…tstrap only when zero admins Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…dation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…er lookups Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace all console.log/error calls with a pino-backed createLogger helper across the worker entrypoint, all five sync jobs, and lib/alerts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
8 targeted fixes identified from a product readiness review, covering security hardening, performance, observability, and UX polish.
Security
auth.ts): Existing users without apasswordHashcan no longer log in via the admin master key — requires an explicit stored hash. Bootstrap (first-time admin creation viaADMIN_PASSWORD) now self-disables once any admin exists, and the bootstrapped account gets its password properly hashed so subsequent logins work.Stability / Correctness
lib/env.ts): Zod schema validatesDATABASE_URL,NEXTAUTH_SECRET,ALLOWED_EMAIL_DOMAINat import time — misconfigured deployments fail fast with a clear message.lib/constants.ts): Risk thresholds, stale-access windows, upload limits, and invite expiry are now named constants used consistently across 5 files.app/api/spend/upload): Returns HTTP 413 before reading file content — prevents OOM on large uploads.Performance
worker/jobs/sync-google.ts,sync-m365.ts): App and user DB lookups are now batched withfindMany+ Map before the grant loop. Previously: O(N×M) round-trips per sync; now: 2 bulk queries + O(N) upserts.Observability
lib/logger.ts): Replaced allconsole.log/errorin worker jobs and alert module withpinochild loggers. Each log line includes{ module, ...context }for filtering in Railway log drains./api/healthendpoint: DB ping (SELECT 1) returns200 okor503 error— ready for Railway health check probe configuration.UX
PATCH /api/access/revoke) that deactivates the grant and auto-resolves the alert.Test Plan
passwordHashis rejectedGET /api/healthreturns{ status: "ok", db: "ok" }with DB connected🤖 Generated with Claude Code