Skip to content

Name the files in protoc messages without the run's temporary directory - #7251

Merged
Koudai Aono (koxudaxi) merged 8 commits into
mainfrom
protobuf-messages-deterministic
Nov 21, 2026
Merged

Koudai Aono (koxudaxi) merged 8 commits into
mainfrom
protobuf-messages-deterministic

Conversation

@koxudaxi

@koxudaxi Koudai Aono (koxudaxi) commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • Protobuf parsing now provides cleaner compiler diagnostics, including source locations for errors. Warnings are shown on successful runs, and temporary directory paths are excluded.
  • Tests
    • Added coverage for protobuf warning and error messages, including checks that warning output remains consistent across runs.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T16:34:10.405785Z 82d8fc0 PR opened
ℹ️ About Codex in GitHub

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

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

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
Walkthrough

The protobuf parser now captures file-descriptor-level stderr from protoc, removes temporary-directory paths from diagnostics, raises SchemaParseError with cleaned details on failure, and writes successful diagnostics to stderr. Tests cover CLI diagnostic content and stderr consistency across hash seeds.

Changes: Protobuf diagnostics

Layer / File(s) Summary
Capture and report compiler diagnostics
src/datamodel_code_generator/parser/protobuf.py
The parser captures protoc diagnostics and removes temporary-directory paths. It raises SchemaParseError with cleaned details on failure, or writes nonempty diagnostics to stderr on success.
Validate CLI and deterministic diagnostics
tests/main/protobuf/test_main_protobuf.py, tests/main/test_generation_determinism.py
CLI tests check warning text and source locations. Determinism tests check expected protobuf warnings and compare stderr across hash seeds.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Low · previous review 82d8f

This change removes the temporary directory from protoc messages. On Windows, the directory may still appear in diagnostics if protoc prints it with forward slashes, which could also make the new diagnostic tests fail there. This is unconfirmed and low impact, so the owner should check the Windows CI results before merging.

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 states the main change: file names in protoc messages no longer include the run's temporary directory. The raw summary says the change strips temporary directory paths from captured protoc d…
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 states the main change: file names in protoc messages no longer include the run's temporary directory. The raw summary says the change strips temporary directory paths from captured protoc diagnostics, and the tests assert the input filename in those messages. The title is specific and matches the changeset, so it passes.

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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@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: 82d8fc0f1e

ℹ️ 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 (@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 (@codex) address that feedback".

@github-actions

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai 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.

Additional comments: 1

src/datamodel_code_generator/parser/protobuf.py-431-431: 1

431-431: Major · Functional Correctness · Quick win

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Match the whole POSIX-form temporary path on Windows.

The protobuf source bundled with supported grpcio-tools==1.62.0 normalizes Windows disk paths to forward slashes and prints those paths in diagnostics. (raw.githubusercontent.com)

For a root such as C:\Users\user\AppData\Local\Temp\tmp123, neither current form matches C:/Users/user/AppData/Local/Temp/tmp123/file.proto. Changing only the trailing separator does not remove that prefix. The temporary directory remains in stderr, and the new exact-message and cross-run tests fail on Windows.

Include the POSIX forms of both roots in this existing cleaner. Retain the native forms. Based on learnings, match both native and POSIX path representations.

Source: Learnings

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 636c22f and 82d8fc0.

Files selected for processing: 3

  • src/datamodel_code_generator/parser/protobuf.py
  • tests/main/protobuf/test_main_protobuf.py
  • tests/main/test_generation_determinism.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@codspeed

codspeed Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 15.93%

2 warnings

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ 40 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚡ 40 improved benchmarks
✅ 13 untouched benchmarks
⏩ 98 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_perf_recommend_options_full_kubernetes_style 26.5 s 19.4 s +36.42%
⚡ test_perf_load_pyproject_config[mapping-multiple] 288.8 µs 230.3 µs +25.4%
⚡ test_perf_load_pyproject_config[config-None] 270.9 µs 216.1 µs +25.37%
⚡ test_perf_load_pyproject_config[mapping-None] 270.8 µs 217 µs +24.76%
⚡ test_perf_load_pyproject_config[config-multiple] 286.5 µs 229.9 µs +24.62%
⚡ test_perf_client_calls[async] 48.3 ms 38.8 ms +24.25%
⚡ test_perf_client_calls[sync] 43.7 ms 35.4 ms +23.64%
⚡ test_perf_target_render[fastapi-large] 11 s 9.3 s +18.3%
⚡ test_perf_deep_nested 5.7 s 4.8 s +18.3%
⚡ test_perf_all_options_enabled 6.7 s 5.8 s +16.86%
⚡ test_perf_large_models_pydantic_v2 4 s 3.4 s +16.65%
⚡ test_perf_extreme_large_schema 16.5 s 14.1 s +16.53%
⚡ test_perf_false_reference_validation 420.9 ms 361.4 ms +16.47%
⚡ test_perf_complex_refs 2.3 s 2 s +16.44%
⚡ test_perf_target_render[client-large] 17.8 s 15.3 s +16.21%
⚡ test_perf_multiple_files_input 4.6 s 3.9 s +16.07%
⚡ test_perf_aws_style_openapi_pydantic_v2 2.3 s 2 s +15.13%
⚡ test_perf_openapi_large 3.5 s 3 s +14.86%
⚡ test_perf_stripe_style_pydantic_v2 2.4 s 2 s +14.83%
⚡ test_perf_kubernetes_style_pydantic_v2 2.8 s 2.5 s +14.4%
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing protobuf-messages-deterministic (b3ab92c) with main (b88b9e3)

Open in CodSpeed

Footnotes

  1. 98 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@codecov

codecov Bot commented Nov 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@koxudaxi
Koudai Aono (koxudaxi) merged commit 047df77 into main Nov 21, 2026
119 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the protobuf-messages-deterministic branch November 21, 2026 00:41
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: The PR moves the formatter's subprocess call into a new private helper module with the same command and arguments, and runs protoc as a separate Python process using the grpc_tools protoc script, which appends the same well-known include path last as before, so the descriptor set and generated models do not change. Protoc diagnostics are now captured with the temporary directory stripped from paths. Invalid schemas still raise the same SchemaParseError with the same exit code, and the message now includes the real protoc diagnostic instead of the old fallback text. Warnings from successful runs still reach stderr, now without temp-dir paths. These are bug fixes and better error messages, not breaking changes. The removed format.subprocess import and the changed _load_grpc_tools signature are internal, not public API. The behaviour diff gate lists only both-fail cells, with no accepted or violation cells, so default output is unchanged. One edge case is not counted as breaking: frozen or embedded interpreters whose sys.executable cannot run the grpc_tools script could now fail.


This analysis was produced by the release draft workflow

@github-actions

Copy link
Copy Markdown
Contributor

🎉 Released in 0.100.0

This PR is now available in the latest release. See the release notes for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant