Skip to content

[codex] add sync Python HTTP client - #14

Merged
calvin-archastro merged 1 commit into
mainfrom
ci/publish-release-regen-workflows
Jun 12, 2026
Merged

[codex] add sync Python HTTP client#14
calvin-archastro merged 1 commit into
mainfrom
ci/publish-release-regen-workflows

Conversation

@calvin-archastro

@calvin-archastro calvin-archastro commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

What changed

This adds only the hand-maintained synchronous HTTP runtime support needed by regenerated Python SDK output.

  • Adds SyncHttpClient beside the existing async HttpClient.
  • Mirrors request, raw response, path prefix, structured error, refresh-only, and one-shot 401 refresh behavior.
  • Extends tests/test_http_client.py with focused sync HTTP coverage.

No generated SDK files, demos, README usage changes, or generated contract tests are included in this PR.

Diagrams

sequenceDiagram
    participant Resource as Generated sync resource
    participant Runtime as SyncHttpClient
    participant API as Platform API
    Resource->>Runtime: request path method body query
    Runtime->>API: HTTP request with bearer token
    alt token expired
        API-->>Runtime: HTTP 401
        Runtime->>Runtime: call refresh handler
        Runtime->>API: retry request
    else success
        API-->>Runtime: JSON response
    end
    Runtime-->>Resource: parsed value
Loading
classDiagram
    class SyncHttpClient {
        request(path, method, body, headers, query)
        request_raw(path, method, body, headers, query)
        set_access_token(token)
        set_refresh_handler(handler)
        close()
    }
    class HttpClient {
        async request(path, method, body, headers, query)
        async request_raw(path, method, body, headers, query)
        set_access_token(token)
        set_refresh_handler(handler)
        async close()
    }
    class GeneratedResource {
        method()
    }
    GeneratedResource ..> SyncHttpClient : uses
Loading

Scope

Python SDK runtime only.

Risk assessment

Medium. This adds a new runtime path for generated sync resources, but it is isolated from the existing async HttpClient and covered with focused unit tests.

User impact

No immediate public API change in this PR alone. Once generator output is regenerated, sync PlatformClient resources can call this runtime directly.

Testing

Passed locally:

  • PYTHONDONTWRITEBYTECODE=1 uv run pytest tests/test_http_client.py -p no:cacheprovider
  • uv run ruff check src/archastro/platform/runtime/http_client.py tests/test_http_client.py
  • uv run ruff format --check src/archastro/platform/runtime/http_client.py tests/test_http_client.py
  • git diff --check

Follow-ups and known issues

@archastro

archastro Bot commented Jun 12, 2026

Copy link
Copy Markdown

✅ Clean PR, @calvin-archastro! No blocking findings on a8a4ab1 — a few nice things I clocked:

  • Clean mirror of the async runtime in SyncHttpClient — same _transform_path prefix logic, _parse_error structured errors, refresh_only auth-path guard, and one-shot 401 refresh, consistent with sync-http-client-mirrors-async. 🎯
  • Nice coalescing on the sync 401 path — threading.Lock plus the if self._get_token() == original_token double-check stops concurrent callers from stampeding the refresh handler.
  • Solid red-green discipline — tests lock in both happy and failure modes (401 retry, refresh-only guard, runner reject-after-close, and the example's leave-raises socket cleanup). 🙌

Reply @archastro <verb>: review · do <pattern> · don't <pattern> · forget <slug> · list

@calvin-archastro
calvin-archastro force-pushed the ci/publish-release-regen-workflows branch from ff1daac to 4d83d2e Compare June 12, 2026 18:35
@calvin-archastro calvin-archastro changed the title [codex] add sync Python runtime support and demos [codex] add sync Python HTTP client Jun 12, 2026
@calvin-archastro
calvin-archastro marked this pull request as ready for review June 12, 2026 18:42
@calvin-archastro
calvin-archastro merged commit ae742ab into main Jun 12, 2026
3 checks passed
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.

1 participant