14. Debugging and troubleshooting¶
This page collects the switches that make the API and client observable, and the failures that most often cost a developer an afternoon. Each entry names the file or variable that resolves it.
14.1. Observe the API¶
Log level.
CPAT_LOG_LEVEL=4enables debug records and includes request and response bodies in the request log. Level 3 (the default) logs one record per request without bodies. Bodies are also logged for any request that carrieselevate=true.Log mode. With
CPAT_LOG_MODE=combined(the default) each request is one('rest', 'transaction')record holding the request, the response, and per-operation statistics. Any other value splits it intorequestandresponserecords, which is easier to read when a request hangs.Reading a record. Every line is JSON with
date,level,component,type, anddata. Filter oncomponent(mysql,rest,oidc,server,tenable) andtype. The schema is in Logging.Response validation.
CPAT_DEV_RESPONSE_VALIDATION=logOnlymakes the OpenAPI validator log a('rest', 'responseValidation')record whenever a response does not match its schema. Run with it on while you build an operation.Operation statistics.
GET /api/op/appinfo?elevate=truereturns per-operation counts, durations, and error totals accumulated since the process started.The availability gate. A
503with a JSON body of the process state means a dependency is not ready. The body shows the database and identity provider flags; read theoidcandmysqlrecords above it in the log for the cause.api/healthcheck.jsperforms the same probe a container does.Node inspector. Start the API with
node --inspect index.jsfromapi/and attach an editor or Chrome DevTools to port 9229. The API has no build step, so breakpoints land in the source you edit.
14.2. Observe the client¶
Source maps. The development configuration in
angular.jsonemits them; the browser debugger shows the TypeScript source.Angular DevTools. The browser extension shows the component tree and the value of each signal, which is the fastest way to confirm that a template is reading a stale field rather than a signal.
Vitest UI.
npm run test:uiruns specs with a browser interface and re-runs on save.Bundle analysis.
npm run analyzeprints the largest inputs per chunk after a production build; use it when the initial bundle budget inangular.jsonis exceeded.Browser launch configuration. The dev server listens on port 4200; if your editor’s launch configuration points elsewhere, correct the port there.
14.3. Failure signatures¶
Symptom |
Cause |
Fix |
|---|---|---|
|
The lockfile was regenerated without |
Run |
|
The development index page is git-ignored and must be created per checkout. |
Copy |
API startup fails with |
An operation’s |
Align the |
A request returns |
The parameter is not declared in the contract, or its type does not match; the validator rejects unknown query parameters and does not coerce types. |
Declare the parameter in |
Every request returns |
The availability gate: the database or the identity provider is not ready, or the pool emptied and the monitor is retrying. |
Read the |
API startup fails on an insecure signing key |
The identity provider publishes a demonstration key the API refuses. |
On a development machine using the demonstration realm only, set |
API startup fails with |
The server is below the minimum in |
Upgrade MySQL to 8.0.24 or later. |
The client loops back to the sign-in page, or shows a blank page after sign-in |
One of the two OIDC clients did not authenticate. Both the |
Check the realm’s clients and their valid redirect URIs, and the |
The client stays on |
A |
Fix |
Swagger UI’s Authorize button ends on an error page |
|
Add it to the client in the realm, or set the variable to a registered value. |
A view shows data that is up to half an hour old, or a reload seems to do nothing |
The upstream data cache served a stored STIG Manager or Tenable response. |
Expected for dashboards. For exports and verification actions, pass the |
A component’s view does not update after data arrives |
A plain field was assigned inside a subscription; under OnPush the view is not re-rendered. |
Hold the value in a signal. See Frontend guide. |
Data from an earlier selection overwrites a later one |
A cached response returned at once while an older network response was still in flight. |
Add a generation counter to the load. See Frontend guide. |
A date test fails in the evening and passes in the morning |
The spec or the code uses local time and the machine’s day has not rolled over the same way as UTC. |
Re-run with |
A formatter run changes every file in the tree |
One package’s Prettier configuration was applied to the other package, or line endings were converted. |
Discard the changes and run |
The documentation build reports |
Git Bash rewrote the Docker volume path and the container saw an empty directory. |
Run the build from PowerShell, or set |
The documentation build fails in CI with a warning |
The |
Build locally with |
Migration fails and every restart fails on the same statement |
A DDL statement committed before a later statement in the file failed, so the re-run hits an already-applied change. |
Make the statements tolerant of a re-run. See Add a database migration. |
A Tenable operation answers |
|
Set |
A Tenable operation answers |
The upstream request failed or timed out; the log has a |
Check reachability from the API host and raise |