Summary
Monitoring ingest currently persists raw query-string context and uses dual persistence paths for api_metrics, creating sensitive-data exposure risk and potentially inconsistent metrics records.
Evidence
Request context extracts all query params:
/Users/jono/production/PageSpace/packages/lib/src/logging/logger-config.ts:58
Middleware forwards query into ingest payload:
/Users/jono/production/PageSpace/apps/web/src/middleware/monitoring.ts:357
Ingest route persists query inside system_logs.metadata:
/Users/jono/production/PageSpace/apps/web/src/app/api/internal/monitoring/ingest/route.ts:114
Redaction list does not include common OAuth params like code/state:
/Users/jono/production/PageSpace/packages/lib/src/logging/logger.ts:133
API metrics written through both buffered middleware flush and ingest path:
/Users/jono/production/PageSpace/apps/web/src/middleware/monitoring.ts:88
/Users/jono/production/PageSpace/apps/web/src/app/api/internal/monitoring/ingest/route.ts:74
Why This Matters
OAuth and similar endpoints can leak sensitive query artifacts into persisted logs.
Two write paths to api_metrics increase risk of inconsistent or duplicate records and complicate incident correlation.
Proposed Work
Implement query-param allowlist or sensitive-key denylist before persistence.
Redact sensitive query values (code, state, tokens, secrets, etc.) at ingest boundary.
Consolidate api_metrics to a single authoritative persistence path (or mark source + dedupe deterministically).
Align this with issue [Monitoring] Session ID preservation #538 so correlation fields remain complete.
Acceptance Criteria
Sensitive query params are not persisted in raw form.
api_metrics write path is single-source or explicitly deduplicated with source attribution.
Tests cover redaction for OAuth callback-style query params and metric-path consistency.
Summary
Monitoring ingest currently persists raw query-string context and uses dual persistence paths for
api_metrics, creating sensitive-data exposure risk and potentially inconsistent metrics records.Evidence
/Users/jono/production/PageSpace/packages/lib/src/logging/logger-config.ts:58/Users/jono/production/PageSpace/apps/web/src/middleware/monitoring.ts:357system_logs.metadata:/Users/jono/production/PageSpace/apps/web/src/app/api/internal/monitoring/ingest/route.ts:114code/state:/Users/jono/production/PageSpace/packages/lib/src/logging/logger.ts:133/Users/jono/production/PageSpace/apps/web/src/middleware/monitoring.ts:88/Users/jono/production/PageSpace/apps/web/src/app/api/internal/monitoring/ingest/route.ts:74Why This Matters
api_metricsincrease risk of inconsistent or duplicate records and complicate incident correlation.Proposed Work
code,state, tokens, secrets, etc.) at ingest boundary.api_metricsto a single authoritative persistence path (or mark source + dedupe deterministically).Acceptance Criteria
api_metricswrite path is single-source or explicitly deduplicated with source attribution.