Skip to content

fix: validate log containers before generated normalization - #228

Merged
swkeever merged 3 commits into
mainfrom
skeever/sdk-python-log-boundaries
Sep 22, 2026
Merged

swkeever merged 3 commits into
mainfrom
skeever/sdk-python-log-boundaries

Conversation

@swkeever

@swkeever swkeever commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

The generated HTTP adapter could turn an invalid data: {} response into an empty list, or raise inconsistent errors for missing metadata. Validate response envelopes, row collections, and required metadata before generated deserialization, using the same checks as the facade. Retain generated model normalization for valid responses, including timestamps.

Run 40 malformed-response cases through both the facade fixture and real HTTP adapter (80 tests), including each missing required field. Non-object bodies, invalid row containers, and malformed metadata consistently raise TypeError. Document the response requirements.

Validation: 22 container cases and three missing-metadata cases failed through the native HTTP adapter before their fixes. uv run poe quality passed with 1,436 tests, strict typing, generator comparison, contract-binding checks, and wheel/sdist consumer tests. The targeted suite passes 108 tests with 100% line and branch coverage for the logs facade and shared response validation. Hosting's contract/harness unit tests passed; shared scenarios are unchanged.

@swkeever

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-22T12:27:56.369146Z dfd4de5 Manual request
🔒 Security Review ✅ Completed 2026-09-22T12:28:58.705599Z dfd4de5 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 15f785cd08

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 15f785cd08

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +25 to +29
transport = FakeLogsTransport()
payload = {"data": data, "limit": 25, "has_more": False, "total": 0}
transport.search_response = FakeResponse(200, payload, {})
transport.activity_response = FakeResponse(200, payload, {})
logs = logs_client(transport).logs

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Exercise row validation through the HTTP adapter

When the generated HTTP adapter receives {"data": {}}, both generated response models iterate the empty mapping as a zero-element collection and serialize it back as [], so the facade accepts the malformed response. This test injects the payload after generated deserialization via FakeLogsTransport, allowing its {} case to pass while the real client remains broken; run the row cases through make_client as well, as the metadata test does.

Useful? React with 👍 / 👎.

Comment on lines +12 to +16
transport = FakeLogsTransport()
transport.search_response = FakeResponse(200, payload, {})
transport.activity_response = FakeResponse(200, payload, {})
logs = logs_client(transport).logs
read = logs.search if operation == "search" else logs.activity

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Test non-object bodies at the HTTP boundary

For an actual 200 response whose JSON body is [] or "invalid", the generated model's from_dict raises KeyError or ValueError before _response_values runs, rather than the asserted TypeError with Expected a complete log response. Injecting these values through FakeLogsTransport bypasses that parser and makes the test claim a consistent failure mode that real SDK users do not receive; exercise these cases with make_client and normalize the generated parse failures.

Useful? React with 👍 / 👎.

@swkeever swkeever changed the title test: cover malformed log response boundaries fix: validate log containers before generated normalization Sep 22, 2026
@swkeever

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: a2611d23f1

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a2611d23f1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/volcano_sdk/_transport.py Outdated
def _validate_log_data(response: _RawHTTPResponse) -> None:
if response.status_code == HTTP_OK:
payload = GeneratedTransport._raw_response(response).payload
_ = response_data(response_values(payload))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate missing log metadata before generated parsing

When a 200 response has a valid data list but omits limit or has_more for search, or total for activity, this check succeeds and the generated model then raises KeyError from its required-field pop() before the facade can produce the documented TypeError("Expected a complete log response"). Validate these required metadata fields at this raw-response boundary as well so malformed envelopes have the promised, consistent failure mode.

Useful? React with 👍 / 👎.

@swkeever

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: dfd4de56a7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: dfd4de56a7

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@swkeever
swkeever marked this pull request as ready for review September 22, 2026 12:30
@swkeever
swkeever requested a review from a team as a code owner September 22, 2026 12:30
@swkeever
swkeever merged commit 9ddf005 into main Sep 22, 2026
7 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