Skip to content

fix(backend): report a failed fact verification instead of an empty success - #193

Open
mac146 wants to merge 1 commit into
AOSSIE-Org:mainfrom
mac146:fix/report-fact-verifier-errors
Open

mac146 wants to merge 1 commit into
AOSSIE-Org:mainfrom
mac146:fix/report-fact-verifier-errors

Conversation

@mac146

@mac146 mac146 commented Nov 22, 2026 •

Copy link
Copy Markdown

Fixes #191

Problem

run_fact_check_pipeline never looked at the status returned by run_fact_verifier_sdk. When the verifier fails (a Groq error or rate limit), it returns {"status": "error", "error_from": "fact_verification", "message": ...} with no verifications key. The pipeline turned that into ([], None), so run_fact_check returned status: "success" with an empty fact list. The user could not tell a failed check from one that found nothing.

Change

  • backend/app/utils/fact_check_utils.py: if the verifier's status is not "success", return ([], message). The message is the verifier's own, or "Fact verification failed." if it gave none. The existing run_fact_check node already turns an error message into an error response, so it needed no change.
  • backend/tests/test_fact_check.py: three tests. The pipeline returns the verifier's message. It uses the generic message when none is given. The node reports the failure as an error.

The claim-extraction check at the top of the function (state.get("status")) is a separate problem, which the issue leaves to #148 and #150, so I did not touch it.

Tests

The three new tests fail before the change and pass after it. pytest --cov in backend/: 231 passed, coverage 99.68%. One test, test_routes_are_mounted_under_api, fails here with and without my change. I ran it with a newer FastAPI than uv.lock pins, so I believe it is unrelated.

Summary by CodeRabbit

  • Bug Fixes
    • Fact-checking failures now provide a clear error message, including a fallback when no message is available.
    • Errors from fact-checking are now correctly identified in the pipeline.

…uccess

run_fact_check_pipeline returned final.get("verifications", []) without
looking at the status of run_fact_verifier_sdk. When the verifier failed
(for example a Groq error or rate limit) it returns an error dict with no
"verifications" key, so the pipeline answered ([], None) and the route
reported status "success" with an empty fact list.

Return the verifier's message as the error instead, falling back to a
generic one, so the fact_check node reports the failure.

Fixes AOSSIE-Org#191

Signed-off-by: mayank <mayankkumars584@gmail.com>
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The fact-check pipeline now returns an error when fact verification fails. Tests cover verifier responses with and without a message and verify node-level error reporting.

Changes

Fact Verification Error Handling

Layer / File(s) Summary
Return and propagate verifier errors
backend/app/utils/fact_check_utils.py, backend/tests/test_fact_check.py
The pipeline returns an empty verification list and the verifier’s message when verification fails. If the verifier provides no message, the pipeline returns Fact verification failed. Tests check both cases and confirm the node returns an error with error_from set to fact_checking.

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested labels: Backend, Tests

Suggested reviewers: reach2saksham

Merge Risk: Minimal · up to f494f

Failed fact verification is now reported as an error rather than an empty success. The change is small and tested, and I see no merge-blocking risk.

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: a failed fact verification is now reported as an error instead of an empty success. The raw summary confirms run_fact_check_pipeline now checks the verifier status, r…
Linked Issues check Passed [#191] Requirement: when run_fact_verifier_sdk returns a non-success status, run_fact_check_pipeline must return the verifier message as the error. The reviewed head of backend/app/utils/fact_check_ut…
Out of Scope Changes check Passed The whole-PR change is limited to the verifier-failure branch in run_fact_check_pipeline (4 added lines in fact_check_utils.py) and three tests in backend/tests/test_fact_check.py. Both directly imple…
Full details: Title check

Explanation

The title states the main change: a failed fact verification is now reported as an error instead of an empty success. The raw summary confirms run_fact_check_pipeline now checks the verifier status, returns an empty verification list with the verifier message (or "Fact verification failed."), and tests cover this. The title matches the changeset and the linked issue #191 scope.

Full details: Linked Issues check

Explanation

[#191] Requirement: when run_fact_verifier_sdk returns a non-success status, run_fact_check_pipeline must return the verifier message as the error. The reviewed head of backend/app/utils/fact_check_utils.py now checks final.get("status") != "success" after Step 3. It returns ([], message), where message is final.get("message") or "Fact verification failed.". The success path still returns verifications with None. This matches the issue's proposed fix. The issue states that run_fact_check turns a non-empty error into an error response with error_from "fact_checking". I did not open the node file, because the path backend/app/nodes/fact_check.py does not exist at head. The node behavior therefore rests on the issue text and the PR's node-level test, which I did not run. The tests described in the PR cover the pipeline message, the generic fallback, and the node error response. The claim-extraction check is not changed, which matches the issue scope.

Full details: Out of Scope Changes check

Explanation

The whole-PR change is limited to the verifier-failure branch in run_fact_check_pipeline (4 added lines in fact_check_utils.py) and three tests in backend/tests/test_fact_check.py. Both directly implement #191. The PR does not modify the claim-extraction status check, which the issue assigns to #148 and #150. No unrelated files are changed according to the supplied summary. The remaining uncertainty is limited to the node file, which I could not open at the given path. That file is not expected to change under the PR summary, so this does not affect the result.

Finishing Touches

Generate unit tests (beta)

  • 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

A rabbit checks the facts with care,
A failed check sends its message there.
If no words come, a fallback stays,
Tests watch the errors through their ways.
The empty list now marks a failed day.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 144a9d3 and f494fe1.

Files selected for processing: 2

  • backend/app/utils/fact_check_utils.py
  • backend/tests/test_fact_check.py

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

@gitcordapp

gitcordapp Bot commented Nov 22, 2026

Copy link
Copy Markdown

Link your account with Gitcord

Thanks for opening this PR, @mac146!

To receive Discord notifications and contributor tracking for this organization:

  1. Join Discord: https://discord.gg/hjUhu33uAn
  2. In Discord, run /link mac146
  3. Paste the verification code into your GitHub bio (or a public gist)
  4. Click Verify in Discord (or run /verify-link mac146)

Once linked, Gitcord can notify you about reviews, merges, and more.

— Posted by Gitcord

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.

[BUG]: A failed fact verification returns an empty success with no error

1 participant