Skip to content

Add GET /reports/{id} endpoint using Spec Driven Development#1

Open
23f3002694-rishi wants to merge 4 commits into
IITMBSMLOps:mainfrom
23f3002694-rishi:main
Open

Add GET /reports/{id} endpoint using Spec Driven Development#1
23f3002694-rishi wants to merge 4 commits into
IITMBSMLOps:mainfrom
23f3002694-rishi:main

Conversation

@23f3002694-rishi
Copy link
Copy Markdown

Summary

Implemented:

GET /reports/{id}

using a Spec Driven Development workflow.

Changes

  • Added OpenSpec artifacts:

    • project.md
    • proposal.md
    • tasks.md
    • spec.md
  • Added helper function in:

    • app/reports.py
  • Added endpoint in:

    • app/main.py
  • Added tests:

    • success case
    • 404 case

Validation

  • Existing endpoints preserved

  • Tests passing (pytest -v)

  • Internal fields not exposed:

    • internal_id
    • owner_email

Commit sequence

spec → feat → test

Copilot AI review requested due to automatic review settings May 25, 2026 15:25
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 returning ReportPublic or 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 thread app/main.py Outdated
Comment on lines +55 to +56
@app.get("/reports/{report_id}", response_model=ReportPublic)
def get_report(report_id: int) -> ReportPublic:
Comment thread app/reports.py
rows = (r for r in rows if r.created_at <= date_to)

return sorted(rows, key=lambda r: getattr(r, sort), reverse=descending)

Comment thread app/main.py
offset=offset,
limit=limit,
)

Comment thread app/reports.py
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
Comment thread tests/test_reports.py Outdated

def test_get_report_found():

response = client.get("/reports/1")
Comment thread tests/test_reports.py Outdated

def test_get_report_missing():

response = client.get("/reports/99999")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants