Skip to content

Commit ab1e052

Browse files
committed
docs: add README for API contract test failures investigation and resolution plan
1 parent cd4ee18 commit ab1e052

File tree

1 file changed

+71
-0
lines changed
  • specs/195-api-contract-test-failures

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
status: planned
3+
created: 2025-12-21
4+
priority: high
5+
tags:
6+
- testing
7+
- api
8+
- contract
9+
- ci
10+
- parity
11+
depends_on:
12+
- 194-api-contract-test-suite
13+
- 191-rust-http-api-test-suite
14+
- 186-rust-http-server
15+
- 192-backend-api-parity
16+
created_at: 2025-12-21T14:11:18.442192Z
17+
updated_at: 2025-12-21T14:11:27.331265Z
18+
---
19+
20+
# API Contract Test Failures (Rust & Next.js)
21+
22+
## Overview
23+
Investigate and fix API contract suite regressions affecting both Rust HTTP server and Next.js API so the shared contract remains a reliable compatibility gate across backends and CI.
24+
25+
## Problem & Motivation
26+
API contract suite (`pnpm -F @leanspec/api-tests test`) fails against both Rust HTTP server and Next.js API, blocking parity confidence and CI stability. Need a focused investigation to isolate regressions and ensure both backends satisfy the shared contract.
27+
28+
## Current Signals / Suspicions
29+
- Failures observed when targeting Rust (port 3001) and Next.js (port 3000) backends.
30+
- Potential drift in response schemas (camelCase vs snake_case) or missing fields.
31+
- Fixture/seed differences between Rust and Next.js project loaders.
32+
- Env/config mismatches for `API_BASE_URL`, project root, or filesystem permissions.
33+
34+
## High-Level Approach
35+
- Reproduce failures for both backends with consistent fixtures and env.
36+
- Triage by endpoint category: health, projects, specs, search, stats, dependencies, validate, error cases, performance envelopes.
37+
- Compare live responses Rust vs Next.js for the failing cases to pinpoint schema/behavior drift.
38+
- Patch minimal changes to bring both backends to the contract (prefer aligning to documented contract in tests/schemas).
39+
- Harden test config and docs to avoid env drift (ports, project paths, seed data).
40+
41+
## Key Decisions
42+
- Which backend is source of truth when behaviors diverge (align to contract or adopt parity to Next.js?).
43+
- Scope of fixes allowed in Rust vs Next.js (behavior vs schema vs fixtures).
44+
- Handling of performance thresholds and error payload shape (standardize or relax?).
45+
46+
## Plan
47+
- Reproduce failing cases for both backends using the same fixtures and documented env vars.
48+
- Categorize failures by endpoint and schema/behavior type; capture diffs Rust vs Next.js.
49+
- Align implementations or adjust contracts to resolve each category, prioritizing minimal, backward-compatible fixes.
50+
- Update troubleshooting guide and CI matrix configuration to lock in passing runs.
51+
52+
## Acceptance Criteria
53+
- [ ] Contract suite passes against Rust server (`API_BASE_URL=http://localhost:3001`).
54+
- [ ] Contract suite passes against Next.js API (`API_BASE_URL=http://localhost:3000`).
55+
- [ ] Documented reproduction steps and required env vars in `tests/api/README.md` (troubleshooting guide included).
56+
- [ ] If behavior gaps remain, tracked follow-ups with linked specs or issues.
57+
- [ ] CI matrix (Rust + Next) green or has explicit, justified allow-fail annotated.
58+
59+
## Out of Scope
60+
- New endpoints or OpenAPI generation.
61+
- UI changes beyond test docs.
62+
- Broader performance tuning outside test thresholds.
63+
64+
## Dependencies
65+
- API contract suite spec and schemas.
66+
- Rust/Next backend implementations and parity efforts.
67+
68+
## Open Questions
69+
- Which port/base URL should be canonical for local CI? (3001 vs 3000)
70+
- Do we standardize error payload structure across backends now or allow divergence?
71+
- Is fixture seeding unified between Rust and Next.js flows?

0 commit comments

Comments
 (0)