6c39bd0a6c
- Fix const inference bug: wrap inferred contracts with status-code guards - Add integration test for status-guarded contract inference - Tighten and deduplicate docs across verify, qualify, getting-started, cli - Fix broken cross-references and TypeScript→JavaScript conversions - Fix factual errors: license, Date.now(), sampling defaults, cache env - Add missing features: --workspace, --generation-profile, json-summary formats - Move stale extension docs (AUTH-RATE-LIMIT-REVISED, HTTP-EXTENSIONS) to attic - Update PLUGIN_CONTRACTS_SPEC status to Implemented - Build: clean | Tests: 849 pass, 0 fail
6.4 KiB
6.4 KiB
Troubleshooting Matrix
Quick reference for common failure classes, symptoms, and resolution steps.
How to use this matrix
- Identify the symptom or error message from your run.
- Match it to the failure class and category.
- Follow the resolution steps in order.
Taxonomy
APOPHIS classifies failures into six categories. Lower categories take precedence when multiple failures occur.
| Category | Description | Examples |
|---|---|---|
parse |
Formula or config syntax errors | Unexpected token, unterminated string |
import |
Module resolution failures | Cannot find module, module not found |
load |
Config or profile loading errors | Config validation failed, profile not found |
discovery |
Route or plugin registration issues | Duplicate route, decorator already added |
usage |
CLI argument or flag errors | Unknown option, missing required argument |
runtime |
Behavioral contract violations | Status mismatch, missing field, equality failure |
Failure Classes
1. Parse Error (parse)
Symptoms
Unexpected tokenin formula outputUnterminated string literalin x-ensures clauseMissing thisin operation call
Resolution
- Check the route and clause index printed in the error message.
- Verify APOSTL syntax: use
response_code(this)notresponse_code(). - Ensure string literals use single or double quotes consistently.
- Run
apophis doctor --profile <name>to validate formulas without executing.
Prevention
- Run
apophis doctor --profile <name>to validate formulas without executing. - Enable editor support for APOSTL syntax highlighting.
2. Import Error (import)
Symptoms
Cannot find module '<path>'Module not foundwhen loading app or config
Resolution
- Verify the file path exists relative to the project root.
- Check that the module is listed in
package.jsondependencies. - Run
npm install(or equivalent) to ensure node_modules is populated. - For ESM projects, verify the file extension matches the import (
.jsfor.tsfiles).
Prevention
- Use absolute paths in
apophis.config.jswhere possible. - Pin dependency versions to avoid resolution drift.
3. Load Error (load)
Symptoms
Config validation failedProfile not foundCannot read file
Resolution
- Verify
apophis.config.js(or.ts,.json) exists in the working directory. - Check that the requested profile is defined in
config.profiles. - Validate config structure against the schema in
docs/cli.md. - Use
apophis doctorto list available profiles and detect config issues.
Prevention
- Run
apophis initto generate a valid starter config. - Commit config files to version control.
4. Discovery Error (discovery)
Symptoms
Plugin decorator already addedDuplicate route registrationNo behavioral contracts found. Schema-only routes are not enough for verify. Add x-ensures or x-requires to route schemas. See docs/getting-started.md for examples.
Resolution
- Ensure the APOPHIS plugin is registered exactly once in the Fastify app.
- Check for multiple imports or plugin registrations in test vs production entry points.
- If
No behavioral contracts found. Schema-only routes are not enough for verify. Add x-ensures or x-requires to route schemas. See docs/getting-started.md for examples., addx-ensuresorx-requiresto route schemas. - Run
apophis doctorto verify route discovery matches expectations.
Prevention
- Use a single app entry point for both production and testing.
- Add contracts during route development, not as an afterthought.
5. Usage Error (usage)
Symptoms
Unknown option --<flag>Missing required argumentInvalid profile name
Resolution
- Run
apophis --helpto see available flags and commands. - Check that the profile name matches a key in
config.profilesexactly. - Verify flag syntax: use
--flag valueor--flag=value, not--flag value1 value2. - For CI environments, use
--format jsonto suppress interactive prompts.
Prevention
- Wrap CLI calls in package.json scripts to standardize flags.
- Validate command syntax in pre-commit hooks.
6. Runtime Behavioral Failure (runtime)
Symptoms
Expected 200, observed 404Missing field: <name>Equality mismatchResponse time exceeded
Resolution
- Read the
Expected/Observed/Why this matterssections in the failure output. - Use the printed
Replaycommand to reproduce the failure locally. - Check the request/response context in the artifact for debugging details.
- For status code mismatches: verify the handler logic and preconditions.
- For missing fields: ensure the handler returns the expected shape.
- For temporal failures (
previous()): stabilize app state or use deterministic test data.
Prevention
- Use
apophis verify --seed <number>for deterministic runs. - Run
apophis observein CI to catch drift before it becomes a failure. - Keep test data isolated and reset between runs.
Artifact-Driven Triage
Every failure produces an artifact JSON file. Use it for deep triage:
# Inspect the artifact
cat reports/apophis/failure-<timestamp>.json | jq '.failures[0]'
# Replay the exact failure
apophis replay --artifact reports/apophis/failure-<timestamp>.json
# Filter by error category
cat reports/apophis/failure-<timestamp>.json | jq '.failures | map(select(.category == "runtime"))'
CI-Specific Guidance
| Symptom | Likely Cause | Fix |
|---|---|---|
| Tests pass locally but fail in CI | Environment drift or nondeterministic data | Pin seed with --seed, isolate external deps |
npx apophis not found in CI |
Package not installed or bin path wrong | Use npm ci and verify package.json bin field |
| Artifact not written in CI | Missing artifactDir or permission issue |
Set --artifact-dir ./artifacts in CI config |
| Slow CI runs | Too many routes or deep presets | Use --profile quick or --routes filter |
| JSON output unreadable | Machine mode lacks human formatting | Use --format json-summary for concise CI logs |
Getting More Help
- Run
apophis doctorfor automated diagnostics. - Check
docs/cli.mdfor command reference. - Review
docs/getting-started.mdfor first-run guidance. - Inspect the artifact file for full request/response context.