Skip to content

Conversation

zhaotai
Copy link
Contributor

@zhaotai zhaotai commented Sep 23, 2025

Summary

  • Add and surface flattened runtime handler metadata across server endpoints (no new endpoints).
  • Replace per-endpoint, hand-built dicts with a single source to_dict() on the server-side wrapper.
  • Consolidate OpenAPI schemas via shared components to remove duplication.
  • Update tests to reflect expected behavioral changes.

API changes (intentional)

  • Flattened metadata fields are now included in these responses:
    • POST /workflows/{name}/run (200)
    • POST /workflows/{name}/run-nowait (200)
    • GET /results/{handler_id} (200, 202)
    • GET /handlers (200, each item)
  • Run-nowait response:
    • status was previously “started”; it now returns status: "running".
  • Get result error response:
    • GET /results/{handler_id} now returns a detailed error as text/plain on 500 (instead of a JSON object).

Implementation details

  • Introduced server-side wrapper _WorkflowHandler.to_dict() returning a typed HandlerDict.
  • Safe accessors on _WorkflowHandler:
    • status: guards unfinished futures and maps to "running" | "completed" | "failed".
    • error: None when unfinished, stringified exception when failed.
    • result: None when unfinished; returns final result when completed.
  • Centralized response construction to avoid ad-hoc dict assembly.
  • OpenAPI:
    • Added shared components:
      • components.schemas.Handler: flattened, reusable handler response shape.
      • components.schemas.HandlersList: { handlers: Handler[] }.
    • Endpoint docstrings now reference $ref to the above, removing duplication.

Backward compatibility notes

  • Run-nowait clients should expect "status": "running" instead of "started".
  • Consumers of GET /results/{handler_id} on error (500) should parse a text/plain body (detailed error message) rather than a JSON object.

Testing

  • Updated server tests to reflect the above behavioral changes.
  • All server tests passing: 72 passed locally.

Migration/Deployment

  • No persistence or schema migrations needed.
  • No new configuration flags introduced.

@zhaotai zhaotai changed the title server: add flattened handler metadata, unify typed responses and Ope… server: flattened handler metadata in responses, shared OpenAPI components, and test updates Sep 23, 2025
@coveralls
Copy link

coveralls commented Sep 23, 2025

Pull Request Test Coverage Report for Build 17960965298

Details

  • 11 of 11 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.01%) to 90.106%

Totals Coverage Status
Change from base Build 17960904376: -0.01%
Covered Lines: 1530
Relevant Lines: 1698

💛 - Coveralls

@zhaotai zhaotai force-pushed the feat/server-metadata-typed branch from bf670ca to e512310 Compare September 23, 2025 22:42
@zhaotai zhaotai merged commit 337e84c into main Sep 23, 2025
6 checks passed
@zhaotai zhaotai deleted the feat/server-metadata-typed branch September 23, 2025 22:49
@logan-markewich logan-markewich added the enhancement New feature or request label Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants