Skip to content

fix(add_docs): report failed inline documentation publication - #3745

Merged
IsmaelMartinez merged 3 commits into
The-PR-Agent:mainfrom
oleksii-tumanov:codex/add-docs-publication-outcome-32eb7a3
Sep 29, 2026
Merged

IsmaelMartinez merged 3 commits into
The-PR-Agent:mainfrom
oleksii-tumanov:codex/add-docs-publication-outcome-32eb7a3

Conversation

@oleksii-tumanov

Copy link
Copy Markdown
Contributor

When /add_docs cannot publish its batch of suggestions and every individual retry returns False, it currently finishes without reporting that nothing was published. This change posts a failure comment and records the command failure through the existing run-status path.

All individual retries still run. A successful retry, an unknown provider result, and an empty documentation result retain their existing behavior.

Validation:

  • 494 focused tests passed, including exhausted publication, partial success, unknown results, empty suggestions, and failure-comment errors.
  • PYTHONPATH=. uv run pytest tests/unittest -q: 9846 passed, 33 skipped, 1 xfailed.
  • Ruff and changed-file pre-commit checks passed.

Provider outcomes were checked with controlled tests; live provider E2E checks were not run.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

fix(add_docs): report exhausted inline documentation publication failure

🐞 Bug fix 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• push_inline_docs now returns a tri-state result (True/False/None) reflecting whether all retries
 failed.
• /add_docs posts a failure comment and raises to trigger the existing record_command_failure
 path when every individual retry returns False.
• Partial success, unknown/ambiguous results, and empty documentation continue to be treated as
 non-failures.
• Added extensive unit tests covering exhausted, partial, ambiguous, empty, and comment-error
 scenarios.
Diagram

graph TD
  A["push_inline_docs"] --> B{"Aggregate publish\nsucceeded?"}
  B -->|True| C["Return True"]
  B -->|False| D["Retry each\nsuggestion"]
  D --> E{"All retries\nFalse?"}
  E -->|Yes| F["Return False"]
  E -->|No| G["Return True/None"]
  F --> H["run(): publish\nfailure comment"]
  H --> I["record_command_failure"]
Loading
High-Level Assessment

Using a tri-state return value (True/False/None) to disambiguate exhausted failure from ambiguous/partial outcomes is a minimal, low-risk fix that reuses the existing failure-comment and record_command_failure infrastructure rather than introducing new error-handling machinery.

Files changed (2) +155 / -8

Bug fix (1) +17 / -3
pr_add_docs.pyReport exhausted inline documentation publication as a failure +17/-3

Report exhausted inline documentation publication as a failure

• push_inline_docs now returns True/False/None to distinguish success, exhausted retries, and ambiguous/empty outcomes. run() posts a failure comment and raises RuntimeError when push_inline_docs returns False, triggering the existing command-failure recording path.

pr_agent/tools/pr_add_docs.py

Tests (1) +138 / -5
test_add_docs_missing_key.pyAdd coverage for inline publication outcome handling +138/-5

Add coverage for inline publication outcome handling

• Extended FakeGitProvider to simulate configurable suggestion results and comment errors, and added tests for exhausted failure, partial success, ambiguous results, empty documentation, and comment-error propagation scenarios.

tests/unittest/test_add_docs_missing_key.py

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Failed docs requests report success ✓ Resolved
Description
PRAddDocs.run() records the exhausted publication failure and then suppresses its RuntimeError,
while _run_command() treats the normal return as success. When a non-automated /add_docs request
exhausts its retries, its request returns True and its span is marked successful; unlike the
automated-check path, it also has no run-details collector initialized to retain the failure flag.
Code

pr_agent/tools/pr_add_docs.py[R82-83]

+                    self.git_provider.publish_comment("Failed to publish code documentation for this PR.")
+                    raise RuntimeError("Failed to publish code documentation after individual retries")
Evidence
The changed branch publishes the failure comment and raises, but run() catches the exception and
calls record_command_failure(). That function has no effect without an initialized collector;
PRAddDocs.run() does not initialize one, whereas the automated GitHub command loop explicitly
does. For ordinary requests, _run_command() unconditionally marks the span OK and returns True
when the tool returns normally.

pr_agent/tools/pr_add_docs.py[80-90]
pr_agent/algo/run_details.py[97-121]
pr_agent/agent/pr_agent.py[400-410]
pr_agent/servers/github_app.py[573-585]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
An exhausted `/add_docs` publication posts a failure comment, but ordinary command handling reports the request as successful because the tool suppresses the exception and no run-details collector is initialized for that path.
## Fix Focus Areas
- pr_agent/tools/pr_add_docs.py[80-86]
- pr_agent/agent/pr_agent.py[400-411]
- pr_agent/algo/run_details.py[97-121]
## Recommended Fix
Initialize run details at the command boundary and have command handling inspect the recorded failure after the tool returns. Return `False` and mark the span as failed when the flag is set, while retaining the existing automated-check behavior.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Docs omit the publication failure outcome ✓ Resolved
Description
PRAddDocs.run() now posts a failure comment and records a command failure when the batch and every
individual retry return False, but the add-docs guide describes only successful inline
publication. Users following that guide have no explanation of the new comment or failed run status
when no suggestion can be published.
Code

pr_agent/tools/pr_add_docs.py[R81-83]

+                if publication_result is False:
+                    self.git_provider.publish_comment("Failed to publish code documentation for this PR.")
+                    raise RuntimeError("Failed to publish code documentation after individual retries")
Evidence
The changed branch publishes a new user-visible failure comment and records failure, while the
guide's workflow description covers inline suggestions without this failure outcome.

Rule 2694680: Update docs when user-facing behavior changes
pr_agent/tools/pr_add_docs.py[80-86]
docs/docs/tools/add_docs.md[65-69]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The add-docs guide does not describe the new failure outcome when all publication attempts fail.
## Fix Focus Areas
- docs/docs/tools/add_docs.md[23-69]
- pr_agent/tools/pr_add_docs.py[80-83]
## Recommended Fix
Add a brief failure-outcome note to the add-docs guide explaining when the failure comment appears and that the command is marked failed.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


  • Author self-review: I have reviewed the code review findings, and addressed the relevant ones.

Grey Divider

Tip of the day
💡 Did you know, you can add REVIEW.md to your repo root and Qodo follows it on every PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 7e25c4e

@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 50e07e0

@IsmaelMartinez
IsmaelMartinez merged commit 2bc5fdd into The-PR-Agent:main Sep 29, 2026
11 checks passed
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.

2 participants