Repository navigation
Conversation
upstream_json() built each result by hand and copied only raw_content and raw_content_truncated, so the status fields added in sahenjp#128 never reached format=json responses. Copy both fields when present and add tests for the requested and not-requested cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
konpan
force-pushed
the
fix/expose-raw-content-status
branch
from
November 15, 2026 10:50
1a98ddd to
c14dd1b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and resulting behavior / 解決する問題と変更後の動作
#128 added
raw_content_statusandraw_content_errortoSearchResultand fills them inAggregator::attach_raw_content(). The README says that withinclude_raw_content=1every result reportsraw_content_status. However,upstream_json()insrc/web/feeds.rsbuilds each result object by hand withjson!and only copiesraw_contentandraw_content_truncated, so the two fields never reach the HTTP JSON (format=json, with or withoutfull=1).Trigger: a running 0.31.2 binary,
/search?q=Rust+tokio+tutorial&format=json&full=1&include_raw_content=1. Every result lacked both fields, including the results pastraw_content_limit, which should carrynot_requested.Before: a result whose page could not be read (
fetch_failed,too_large,render_failed, ...) or that was pastraw_content_limithas noraw_contentand no explanation, so a client cannot tell why the body is missing.After: with
include_raw_content=1, each result carriesraw_content_statusand, where available,raw_content_error, also whenraw_contentitself is absent.json_response_fullinherits this because it extendsupstream_json.Follow-up to #128.
Scope and compatibility / 範囲と互換性
upstream_json()changes (twoif letblocks), plus two unit tests in the same file.SearchResulthas them, which is only when the request asked for raw content (attach_raw_contentruns underif request.include_raw_content). Searches withoutinclude_raw_contentproduce exactly the same JSON as before;json_without_raw_content_request_has_no_status_fieldspins that.skip_serializing_if = "Option::is_none"on the struct fields.SearchItem,ReadPageOutput) have no status fields either. That is a separate tool contract, so it is left out of this PR; happy to open a separate one.Validation / 検証
both_json_forms_report_raw_content_status_and_error(fails before the change:raw_content_statusisNull) andjson_without_raw_content_request_has_no_status_fields(guards the unchanged case).rustfmt --check --edition 2024onsrc/web/feeds.rs(rustfmt.toml): no diff.cargo fmt --all --checkitself was not run; this is the only changed file.cargo test --lib(stable-x86_64-pc-windows-msvc, Windows 11,-j 2): 1061 passed, 1 failed, 1 ignored (after rebasing onto the currentmain, f7639ce). The failure isfetch::pdf::tests::pdf_without_text_requires_ocr: the localpdftotextis xpdf 4.06 (shipped with Git for Windows), not Poppler, and exits 99 ontests/fixtures/empty.pdf. Unrelated to this change.cargo test --all-targets: not run (only--lib; the integration tests intests/were not executed on this machine because of memory limits).tests/integration.rsreads onlyraw_contentandraw_content_truncatedfrom the JSON, so the added fields do not affect it.cargo clippy --all-targets -- -D warnings: not run (same memory limit). Relying on CI for this.Limitations / 残る制約
Contribution notes / 作成・レビューについて
I found the gap while checking the #128 features against a running 0.31.2 build. The patch, the tests and this description were drafted with AI assistance (Claude Code); I reviewed the diff and the check results listed above.
🤖 Generated with Claude Code
日本語の要約
#128 では raw_content_status と raw_content_error が追加されましたが、HTTP の JSON(format=json)にはこの2つの欄が出力されていませんでした。src/web/feeds.rs の upstream_json() が結果の JSON を1件ずつ組み立てる処理で、この2つの欄を加えていなかったためです。
この PR は、upstream_json() が2つの欄を出力するように変更し、その動作を確かめる試験を2本追加します。include_raw_content を指定しない検索の JSON は変わりません。設定・引数・依存関係も変更していません。