Skip to content

fix(logging): the execution log records a row's outcome after its output is validated (ITL-1261) - #640

Merged
eywalker merged 2 commits into
mainfrom
eywalker/itl-1261-the-execution-log-records-the-outcome-after-validation
Nov 28, 2026
Merged

eywalker merged 2 commits into
mainfrom
eywalker/itl-1261-the-execution-log-records-the-outcome-after-validation

Conversation

@eywalker

@eywalker eywalker commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Record a successful execution after its output passes validation. A rejected output records failure and, when the executor supplies a traceback field, the validation traceback alongside the captured I/O.
  • Cover wrong output types and wrong output counts on both the sync and async job paths.

The fix uses the existing log columns, and the golden hash check passed. For this PR and #628, whichever merges second should merge main after the first lands.

Fixes ITL-1261

Review findings and regression coverage

Finding Regression coverage
A lone surrogate in a validation error prevented a UTF-8 log write and masked the row's error. test_validation_traceback_with_lone_surrogate checks the escaped traceback, the failure log row, and the original ValueError on sync and async jobs. Both cases failed with UnicodeEncodeError before the fix.
The rejection tests used a single tag and data column in one layout. test_rejected_output_logged_as_failure checks wrong types and wrong output counts across two tag columns, two data columns, and two physical column and tag orders on sync and async jobs.
A custom executor that omits the traceback field can log a rejected row without its validation reason. The reproduction below records the current behavior. Adding a field to the stored log is outside this patch's scope.

Known limitations

A custom executor's log can omit the validation reason if its record has no field for it. To reproduce, use LoggingObserver with an in-memory database and a custom executor that calls the function, records logger.record(success=True, stdout_log="capture"), and returns the result. Supply one integer and one string return from a function declared to return int. The rejected row has _log_success=False and the captured stdout. The job summary reports OutputTypeError. Adding a traceback column to only the rejected record makes its schema incompatible with the successful record in the same table.

Summary by CodeRabbit

  • Bug Fixes
    • Execution logs now mark runs as failed when their outputs fail validation, rather than recording them as successful.
    • Failure logs include validation details and captured output, making it easier to understand what went wrong. Error messages containing unusual Unicode characters are stored safely.
    • The fix applies to both synchronous and asynchronous execution.
  • Documentation
    • Clarified a limitation: some custom execution setups may not include the validation reason in the failure log, though it remains available in the job summary.

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change defers successful execution-log records until output validation completes. If execution or validation raises, buffered records become failures and include a traceback when the record has a traceback field. Synchronous and asynchronous paths use this behavior, with integration tests and documentation covering the results.

Changes: Execution logging

Layer / File(s) Summary
Defer success records through output validation
src/orcapod/core/data_function.py
A deferred logger buffers success records until execution and output validation complete. If an exception occurs, buffered records become failures, receive the current traceback when they already have a traceback field, and are forwarded before the exception is re-raised. Both synchronous and asynchronous executor paths use this behavior.
Verify and document failure records
tests/test_pipeline/test_logging_observer_integration.py, changelog.d/ITL-1261.md, docs/dev/design_issues/ITL-1261-OBS1261.md
Integration tests cover rejected outputs, captured stdout, retained tags, and traceback escaping for lone surrogates in both orchestrator modes. The changelog and design-issue document describe the fix and the custom-executor limitation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant PythonDataFunction
  participant Executor
  participant DeferredSuccessLogger
  participant OutputValidation
  participant ExecutionLog
  PythonDataFunction->>Executor: Execute with deferred logger
  Executor->>DeferredSuccessLogger: Submit success record
  DeferredSuccessLogger->>DeferredSuccessLogger: Buffer success record
  PythonDataFunction->>OutputValidation: Validate output
  OutputValidation-->>PythonDataFunction: Raise validation exception
  PythonDataFunction->>DeferredSuccessLogger: Mark buffered record as failed
  DeferredSuccessLogger->>ExecutionLog: Forward failure record and traceback
Loading

Possibly related issues

  • Issue #252 also concerns recording failed pods in the async path. This change logs rejected outputs as failures, but does not change pod status handling or async error propagation.
Merge Risk: Minimal · up to b8dc2

Rejected function outputs are now logged as failures instead of successes, with validation tracebacks when the executor supports them. No merge-blocking risk was identified. Custom executors without a traceback field may omit the validation reason, and this is documented.

Security architecture risk: Low · up to b8dc2

The change fixes misleading success records for rejected outputs. It also lets validation exception text reach existing execution logs and can leave a record unwritten if the invocation is interrupted before the log is written. It does not add a new log destination or grant new access.

Retained concerns

  • Low · security · inferred: At base, a callable that returned normally could leave a success record with no traceback even when its output was rejected. At head, the validation exception text is appended to the same execution log when the executor supplied a traceback field. Validation callbacks can emit data-dependent messages; UTF-8 escaping preserves that text rather than redacting it. Sensitive content in those messages would become visible to existing log readers. No broader reader access or actual sensitive disclosure was established.
  • Low · reliability · observed: An interruption outside the Exception hierarchy after a success record has been buffered skips both flush paths. The base had already handed that record to the logger; the head can leave no record for that buffered outcome. This is relevant to executors that can suspend after recording success and to interruptions during validation. The inspected built-in async paths do not suspend after recording success.
  • Low · reliability · observed: The new failure flush calls the logger before re-raising the validation error. If the logger raises, callers receive the logger exception with the validation error chained behind it, and any remaining buffered records are skipped. The built-in observer catches database append exceptions, so this propagation concerns errors outside that guard and custom loggers that raise.
Security review details

Security Blast Radius

  • inferred — The new content is limited to logged invocations with a buffered success containing a traceback field and a subsequent exception. Local and Ray both supply that field. Exposure follows the configured observer database and its existing readers; node-scoped paths do not by themselves establish tenant isolation.

Trust Boundaries and Controls

  • observed — The wrapper forwards records to the original invocation logger, preserving its run, tag, and storage context. It does not grant access to a different sink. The traceback encoding step ensures UTF-8 compatibility, not confidentiality.

Hardening Proposals

  • proposed — Persist a bounded, structured validation diagnostic by default. Make full exception text opt-in under the applicable log access and retention policy.
  • proposed — Define what happens to a buffered outcome on cancellation and logger failure. Preserve the primary validation error if recording also fails, and test interruption and partial flush behavior explicitly.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the execution log now records a row's outcome only after its output passes validation, and it references the ticket ITL-1261. The raw summary confirms the data_functio…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the execution log now records a row's outcome only after its output passes validation, and it references the ticket ITL-1261. The raw summary confirms the data_function.py change defers success records until validation completes, and the tests cover rejected output as failures. The title is specific and accurate, though it is somewhat long at 96 characters.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

Note

This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 37f7843 and b8dc2ca.

Files selected for processing: 4

  • changelog.d/ITL-1261.md
  • docs/dev/design_issues/ITL-1261-OBS1261.md
  • src/orcapod/core/data_function.py
  • tests/test_pipeline/test_logging_observer_integration.py

Limit details: You’ve used the included review currently available. Your 96 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Recent review details

Context from checks skipped due to timeout: 2

  • GitHub Check: CodeRabbit
  • GitHub Check: Tests (3.13)
Additional context used

Code guidelines: 1

CLAUDE.md — auto-discovered
Path-based instructions: 1

Source excerpt: A pull request never edits `CHANGELOG.md` (developer, November 11, 2026; ITL-961).

CodeRabbit inference engine (CLAUDE.md)

Files:

  • changelog.d/ITL-1261.md
Additional comments: 4

src/orcapod/core/data_function.py: 1

9-14: LGTM!

Also applies to: 89-131, 1258-1268, 1290-1300

tests/test_pipeline/test_logging_observer_integration.py: 1

10-12: LGTM!

Also applies to: 15-15, 18-18, 22-22, 120-182, 185-222

changelog.d/ITL-1261.md: 1

1-7: LGTM!

docs/dev/design_issues/ITL-1261-OBS1261.md: 1

1-15: LGTM!

@eywalker

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Posted by a Codex agent on behalf of @eywalker.

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@eywalker
eywalker merged commit 542f6fb into main Nov 28, 2026
10 checks passed
@eywalker
eywalker deleted the eywalker/itl-1261-the-execution-log-records-the-outcome-after-validation branch November 28, 2026 20:22
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