Add GET /reports/{id} endpoint using Spec Driven Development#1
Open
23f3002694-rishi wants to merge 4 commits into
Open
Add GET /reports/{id} endpoint using Spec Driven Development#123f3002694-rishi wants to merge 4 commits into
23f3002694-rishi wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a GET /reports/{id} endpoint for direct report lookup, with accompanying tests and OpenSpec documentation to preserve the existing /reports contract while enabling single-record retrieval.
Changes:
- Added
get_report_by_id()helper to fetch a report by ID from the in-memory dataset. - Added
GET /reports/{report_id}FastAPI route returningReportPublicor a 404 with"Report not found". - Added OpenSpec docs and new tests validating success + 404 behavior and that internal fields are not exposed.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
app/reports.py |
Adds helper to retrieve a single report by ID. |
app/main.py |
Adds new GET /reports/{...} route wiring to the helper and returning ReportPublic. |
tests/test_reports.py |
Adds tests for found/missing report behavior and response shape constraints. |
openspec/project.md |
Documents project context/conventions/constraints relevant to API stability. |
openspec/changes/get-report-by-id/tasks.md |
Tracks implementation tasks for the change. |
openspec/changes/get-report-by-id/specs/reports/spec.md |
Specifies endpoint contract and response behavior. |
openspec/changes/get-report-by-id/proposal.md |
Describes motivation, scope, and non-goals for the endpoint. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+55
to
+56
| @app.get("/reports/{report_id}", response_model=ReportPublic) | ||
| def get_report(report_id: int) -> ReportPublic: |
| rows = (r for r in rows if r.created_at <= date_to) | ||
|
|
||
| return sorted(rows, key=lambda r: getattr(r, sort), reverse=descending) | ||
|
|
| offset=offset, | ||
| limit=limit, | ||
| ) | ||
|
|
Comment on lines
+43
to
+50
| def get_report_by_id(report_id: int) -> Report | None: | ||
| """Return one report by ID or None if missing.""" | ||
|
|
||
| rows = all_reports() | ||
|
|
||
| for report in rows: | ||
| if report.id == report_id: | ||
| return report |
|
|
||
| def test_get_report_found(): | ||
|
|
||
| response = client.get("/reports/1") |
|
|
||
| def test_get_report_missing(): | ||
|
|
||
| response = client.get("/reports/99999") |
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
Implemented:
GET /reports/{id}
using a Spec Driven Development workflow.
Changes
Added OpenSpec artifacts:
Added helper function in:
Added endpoint in:
Added tests:
Validation
Existing endpoints preserved
Tests passing (
pytest -v)Internal fields not exposed:
Commit sequence
spec → feat → test