Skip to content

Fix Azure diff fallback logging - #2869

Merged
IsmaelMartinez merged 3 commits into
The-PR-Agent:mainfrom
LunaMeerkats:fix/2868-azure-diff-fetch-error
Aug 29, 2026
Merged

IsmaelMartinez merged 3 commits into
The-PR-Agent:mainfrom
LunaMeerkats:fix/2868-azure-diff-fetch-error

Conversation

@LunaMeerkats

@LunaMeerkats LunaMeerkats commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • keep Azure DevOps head/base content-fetch filenames and versions visible in CONSOLE logs while retaining file, version, and error as structured fields
  • preserve the existing per-file empty-content fallback instead of returning an empty diff for the whole PR
  • parameterize the inline code-suggestion error path so brace-containing service errors cannot abort the remaining suggestion batch
  • cover both content-fetch failures, rendered console context, and the braced suggestion-error continuation path with provider-level regressions

Fixes #2868.

Validation

  • PYTHONPATH=. python -m pytest tests/unittest/test_azure_devops_provider.py -q — 57 passed
  • focused review regressions — 3 passed; the braced-error test and both rendered-log assertions failed before their respective fixes and pass afterward
  • PYTHONPATH=. python -m pytest tests/unittest -q — 2,589 passed, 6 failed, 1 skipped, 1 xfailed on Windows; all six failures are within the seven previously recorded baseline-limited cases, with one previously flaky timing test passing on this final run
  • python -m compileall -q pr_agent tests — passed (two existing invalid-escape SyntaxWarnings)
  • python -m flake8 ... --select E9,F63,F7,F82 and git diff --check — passed
  • full-file Flake8/pre-commit remain baseline-limited by existing provider lint, import-order, and trailing-whitespace debt; no unrelated auto-edit is included

Provenance

This pull request was prepared and submitted autonomously by OpenAI Codex through @LunaMeerkats. No human review or authorship is claimed.

@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Preserve Azure diffs when content fetches fail

🐞 Bug fix 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Use structured Azure fetch errors to prevent Loguru formatting failures.
• Retain per-file diffs when head or base content retrieval fails.
• Add regressions for both content-fetch fallback paths.
Diagram

graph TD
  A["PR diff"] --> B["Changed file"] --> C{"Head fetch"}
  C -->|success| D{"Base fetch"}
  C -->|failure| E["Empty head"] --> D
  D -->|success| G["File diff"]
  D -->|failure| F["Empty base"] --> G
Loading
High-Level Assessment

The current approach is appropriate: structured Loguru fields avoid interpreting descriptor braces as formatting placeholders, while preserving localized empty-content fallbacks limits one fetch failure to one file side. Escaping interpolated messages or aborting the full diff would be less robust.

Files changed (2) +64 / -8

Bug fix (1) +9 / -8
azuredevops_provider.pyLog Azure content-fetch failures without aborting diffs +9/-8

Log Azure content-fetch failures without aborting diffs

• Replaces interpolated head and base fetch error messages with structured fields, including stringified version descriptors. Fetch failures continue to use empty content for the affected file side, allowing FilePatchInfo generation to proceed.

pr_agent/git_providers/azuredevops_provider.py

Tests (1) +55 / -0
test_azure_devops_provider.pyCover head and base content-fetch fallbacks +55/-0

Cover head and base content-fetch fallbacks

• Adds a focused Azure provider fixture for a single modified file. Regression tests verify that head or base retrieval exceptions still return the file with only the failed side empty.

tests/unittest/test_azure_devops_provider.py

@qodo-code-review

qodo-code-review Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Console logs lose versions ✓ Resolved 🐞 Bug ◔ Observability
Description
Both fetch-failure logs now attach version only as an extra field, while the repository's console
logger explicitly does not print extra fields. As a result, console diagnostics no longer identify
the commit/version whose Azure content fetch failed.
Code

pr_agent/git_providers/azuredevops_provider.py[667]

+                        "Failed to retrieve new file content of {file}",
Relevance

●●● Strong

Recent accepted precedents favor preserving diagnostic context in logs; this finding directly
supports the PR’s stated logging intent.

PR-#2796
PR-#2584
PR-#2491

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The two modified calls provide version only as an extra keyword, but console logging is configured
with the default format and is explicitly documented not to print extra fields, proving that the
previously rendered version disappears from console output.

pr_agent/git_providers/azuredevops_provider.py[666-670]
pr_agent/git_providers/azuredevops_provider.py[718-722]
pr_agent/log/init.py[43-45]

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 updated Azure content-fetch failure messages omit the version from rendered console output because `version` is supplied only as a structured extra field.

## Issue Context
The console logger does not print extra fields. Preserve brace safety by adding `at version {version}` to each static Loguru message while continuing to pass `version=str(...)` as a keyword argument; Loguru will format that value without reparsing braces inside it.

## Fix Focus Areas
- pr_agent/git_providers/azuredevops_provider.py[666-670]
- pr_agent/git_providers/azuredevops_provider.py[718-722]
- pr_agent/log/__init__.py[43-45]

ⓘ 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

Context sources
✅ Compliance rules (platform): 34 rules
Review mode: ⚖️ Balanced

Grey Divider

Tip of the day
💡 Did you know, you can group findings by type and pick your Finding display, from Minimal to Full

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@IsmaelMartinez IsmaelMartinez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the fast turnaround. I reverted the source file and both new tests go red.

Two suggestions inline, for the CLI case where the extras are dropped.

There is also a third call with the same shape at line 260, get_logger().exception(f"...{e}", suggestion=suggestion). publish_code_suggestions has no outer try, so a brace in the error text aborts the remaining suggestions. Could you fold it into this PR?

@LunaMeerkats

Copy link
Copy Markdown
Contributor Author

Thanks @IsmaelMartinez — addressed in e6c8ad42.

  • Both content-fetch messages now interpolate {file} in the Loguru template, so CONSOLE retains the filename while JSON keeps file, version, and error as structured fields.
  • The inline suggestion failure at the former line 260 now parameterizes {error} instead of embedding exception text before passing suggestion metadata.
  • Added a regression with a brace-containing service error. It failed before the fix because logging raised KeyError and aborted the batch; it now continues to the next suggestion and publishes the failed item through the existing fallback.

Validation: the three focused regressions pass, the full Azure provider module passes 57/57, compileall/critical Flake8/diff checks pass, and the broad suite is 2,588 passed with the same seven unrelated Windows/baseline failures previously recorded.

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit e6c8ad4

@LunaMeerkats

Copy link
Copy Markdown
Contributor Author

Follow-up on the automated console-observability finding: confirmed and fixed in 23bfa077.

Both Azure fetch messages now render {file} and {version} in CONSOLE output while retaining file, version, and error as structured fields. The two fallback regressions now capture rendered Loguru messages and assert the relevant head/base SHA is visible; the affected module passes 57/57. The final broad Windows run is 2,589 passed, 6 failed, 1 skipped, and 1 xfailed, with all six failures drawn from the previously recorded baseline-limited set.

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 23bfa07

@IsmaelMartinez IsmaelMartinez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving.

Thanks for picking up both my review and Qodo's console finding, and for folding in the third call site as asked.

Reverting the provider file to main takes all three new tests red, the braced-error case with KeyError: "'reason'", so the coverage is real rather than incidental. Your fix also goes further than my suggestion did: mine restored the path but left the version out.

@IsmaelMartinez
IsmaelMartinez merged commit 96f10f4 into The-PR-Agent:main Aug 29, 2026
5 checks passed
@naorpeled naorpeled added the bug label Aug 29, 2026
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.

[Bug]: one failed file fetch empties the whole Azure DevOps PR diff, because the error handler itself raises

3 participants