Skip to content

fix(agent/tools): surface github search error responses - #17064

Merged
yuzhichang merged 2 commits into
infiniflow:mainfrom
Yurii214:fix/github-search-error-handling
Jul 20, 2026
Merged

yuzhichang merged 2 commits into
infiniflow:mainfrom
Yurii214:fix/github-search-error-handling

Conversation

@Yurii214

Copy link
Copy Markdown
Contributor

Summary

agent/tools/github.py indexes response["items"] directly after requests.get(...).json(). the github search api returns {"message": ...} without an items key on realistic conditions — a rate limit (403/429; this tool sends no auth token, so the unauthenticated ~10 req/min search limit is easy to hit) or an invalid query (422). that raised KeyError('items'), which the tool's retry loop then surfaced to the model as the opaque "GitHub error: 'items'" instead of the real reason.

this guards the missing key and raises the api's actual message (with a clear fallback) into the existing retry/_ERROR path, so the model sees e.g. "GitHub error: API rate limit exceeded ...". valid responses are unchanged.

adds test/unit_test/agent/tools/test_github_unit.py covering the rate-limit response (asserts the real message is surfaced, no KeyError) and the normal result path.

the github search api reports rate limits (403/429) and invalid queries
(422) through a "message" field with no "items". the github tool indexed
response["items"] directly, so those cases raised KeyError('items'),
which the retry loop reported to the model as the opaque
"GitHub error: 'items'".

guard the missing key and surface the api's actual message (with a clear
fallback) through the existing retry/_ERROR path instead. adds a
regression test covering the rate-limit response and the normal result path.
@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4e3a1da2-4beb-4e73-bcc1-e53443ded081

📥 Commits

Reviewing files that changed from the base of the PR and between 1c0432a and 5d2e3c6.

📒 Files selected for processing (2)
  • agent/tools/github.py
  • test/unit_test/agent/tools/test_github_unit.py
 ______________________________________________
< Looking for trouble in all the right places. >
 ----------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ

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

Comment @coderabbitai help to get the list of available commands.

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. 🌈 python Pull requests that update Python code 🐞 bug Something isn't working, pull request that fix bug. 🧪 test Pull requests that update test cases. labels Jul 17, 2026
@Harry-Hz-Zhang Harry-Hz-Zhang added the ci Continue Integration label Jul 20, 2026

@Harry-Hz-Zhang Harry-Hz-Zhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Yurii214, LGTM

@Harry-Hz-Zhang Harry-Hz-Zhang added lgtm This PR has been approved by a maintainer ci Continue Integration and removed ci Continue Integration labels Jul 20, 2026
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.65%. Comparing base (3da2425) to head (37c8076).
⚠️ Report is 26 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #17064   +/-   ##
=======================================
  Coverage   90.65%   90.65%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          650      650           
  Misses         39       39           
  Partials       28       28           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yuzhichang
yuzhichang merged commit aff9ff6 into infiniflow:main Jul 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration lgtm This PR has been approved by a maintainer 🌈 python Pull requests that update Python code size:S This PR changes 10-29 lines, ignoring generated files. 🧪 test Pull requests that update test cases.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants