Fix strict adjusted history diagnostic precedence - #300
Conversation
Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f6f242e75f
ℹ️ 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".
| "strict_adjusted_history:invalid_request_outcome" | ||
| ) from None | ||
|
|
||
| observed_sessions = tuple(_strict_history_session(bar) for bar in bars) |
There was a problem hiding this comment.
Classify request failures before parsing returned sessions
When a custom requester reports a provider error or missing completion together with a malformed partial bar (for example, a bar whose date is absent or invalid), this eager conversion raises strict_adjusted_history:invalid_bar_session before the documented precedence is applied. The caller therefore loses the higher-priority provider_error/completion_not_observed classification and receives no sanitized diagnostic; classify those request-level states before parsing sessions, or tolerate invalid sessions while constructing their diagnostics.
Useful? React with 👍 / 👎.
| for code in provider_error_codes | ||
| ): | ||
| raise ValueError | ||
| bars = tuple(outcome.bars) |
There was a problem hiding this comment.
Sanitize failures while materializing requester bars
When a custom requester returns a valid StrictAdjustedHistoryRequestOutcome whose bars is a provider-backed or lazily decoded Sequence, an exception raised during iteration (such as RuntimeError or an I/O exception) escapes here because the requester call has already left the outer transport try and this block catches only TypeError and ValueError. That exposes the raw provider exception—including potentially sensitive message text—and bypasses both StrictAdjustedHistoryError and its sanitized transport diagnostic; materialization failures should be translated through the same transport-error path.
Useful? React with 👍 / 👎.
| diagnostic=diagnostic, | ||
| ) | ||
|
|
||
| candles = tuple(_strict_history_candle(bar) for bar in bars) |
There was a problem hiding this comment.
Reuse the validated session when constructing candles
When a custom requester supplies bar objects whose date attribute is mutable, computed, or concurrently updated, the session is read once for the exact-match check and then read again here by _strict_history_candle. If it changes between those reads, the function can return an exact_match diagnostic while the returned candle contains an unexpected session, violating the strict session contract; cache the validated sessions or construct candles without rereading each bar's date.
Useful? React with 👍 / 👎.
Summary
ADJUSTED_LASTdiagnostic contractSafety
Verification
17 passed, 10 subtests passedfocused tests922 passed, 1 skipped, 86 subtests passedfull tests