`nh search` error decoding response body
my env is detsys + nix-darwin + flake, nh is install in system packages i observed nh version is a little bit weird, i can see the version 4.1.2 in /nix/store but it actually shows 4.1.1
$ nh --version
nh 4.1.1
$ ls -l $(which nh)
lrwxr-xr-x 1 root wheel 59 Jan 1 1970 /run/current-system/sw/bin/nh -> /nix/store/ddryjzbjsfksgzxxw5mvm3hb55axk3fq-nh-4.1.2/bin/nh
$ /nix/store/ddryjzbjsfksgzxxw5mvm3hb55axk3fq-nh-4.1.2/bin/nh --version
nh 4.1.1
run nh search fastfetch -v i see below output.
TRACE nh::logging:86: Logging OK
DEBUG nh:28: Main {
verbose: true,
command: Search(
SearchArgs {
limit: 30,
channel: "nixos-unstable",
platforms: false,
json: false,
query: [
"fastfetch",
],
},
),
}
DEBUG nh:29: NH_VERSION=4.1.1 NH_REV=Some("v4.1.2")
DEBUG nh::commands:160: cmd=Exec { nix --version }
DEBUG nh::commands:160: cmd=Exec { nix --version }
TRACE nh::search:58: args: SearchArgs { limit: 30, channel: "nixos-unstable", platforms: false, json: false, query: ["fastfetch"] }
DEBUG nh::search:72: query_s="fastfetch"
Querying search.nixos.org, with channel nixos-unstable...
TRACE reqwest::blocking::wait:49: (ThreadId(1)) park without timeout
TRACE reqwest::blocking::client:1237: (ThreadId(3)) start runtime::block_on
DEBUG nh::search:133: req=Request { method: POST, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("search.nixos.org")), port: None, path: "/backend/latest-43-nixos-unstable/_search", query: None, fragment: None }, headers: {"content-type": "application/json", "user-agent": "nh/4.1.1", "authorization": Sensitive} }
TRACE reqwest::blocking::wait:16: wait at most 30s
TRACE reqwest::blocking::wait:42: (ThreadId(1)) park timeout 29.9999964s
TRACE hyper_util::client::legacy::pool:671: checkout waiting for idle connection: ("https", search.nixos.org)
DEBUG reqwest::connect:625: starting new connection: https://search.nixos.org/
DEBUG reqwest::connect:501: proxy(http://127.0.0.1:7890) intercepts 'https://search.nixos.org/'
TRACE hyper_util::client::legacy::connect::http:481: Http::connect; scheme=Some("http"), host=Some("127.0.0.1"), port=Some(Port(7890))
DEBUG hyper_util::client::legacy::connect::http:769: connecting to 127.0.0.1:7890
DEBUG hyper_util::client::legacy::connect::http:772: connected to 127.0.0.1:7890
TRACE reqwest::connect:564: tunneling HTTPS over proxy
TRACE hyper_util::client::legacy::client:581: http1 handshake complete, spawning background dispatcher task
TRACE hyper_util::client::legacy::pool:713: checkout dropped for ("https", search.nixos.org)
DEBUG nh::search:139: elapsed=205.645905ms
TRACE nh::search:140: response=Response { url: "https://search.nixos.org/backend/latest-43-nixos-unstable/_search", status: 400, headers: {"content-type": "text/plain; charset=utf-8", "connection": "close"} }
Took 205ms
Most relevant results at the end
TRACE reqwest::blocking::wait:16: wait at most 30s
TRACE reqwest::blocking::wait:42: (ThreadId(1)) park timeout 29.999985022s
TRACE reqwest::blocking::client:1180: closing runtime thread (ThreadId(3))
TRACE reqwest::blocking::client:1182: signaled close for runtime thread (ThreadId(3))
TRACE reqwest::blocking::client:1234: (ThreadId(3)) Receiver is shutdown
TRACE reqwest::blocking::client:1239: (ThreadId(3)) end runtime::block_on
TRACE reqwest::blocking::client:1241: (ThreadId(3)) finished
TRACE reqwest::blocking::client:1184: closed runtime thread (ThreadId(3))
Error:
0: parsing response into the elasticsearch format
1: error decoding response body
2: invalid type: integer `400`, expected struct SearchResponse at line 1 column 3
Location:
src/search.rs:150
Cannot reproduce on mainline Nix.
i am using nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05", x86_64-darwin
It's failing on a 400 error. Make sure you can connect to search.nixos.org.
I've improved the error behavior in recent commits. Please see if the error persists with nh built from the master branch, and provide the new --verbose output if it does.
It's failing on a 400 error. Make sure you can connect to search.nixos.org.
i am sure it's connectable. but seems /backend/latest-43-nixos-unstable/_search needs auth
NH establishes the authenticated connection during search.
NH establishes the authenticated connection during search.
from the debug log, username: "" and password: None.
req=Request { method: POST, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("search.nixos.org")), port: None, path: "/backend/latest-43-nixos-unstable/_search", query: None, fragment: None }, headers: {"content-type": "application/json", "user-agent": "nh/4.1.1", "authorization": Sensitive} }
See the relevant bit for auth handling.
Though I doubt that is the issue. From your logs:
TRACE hyper_util::client::legacy::pool:671: checkout waiting for idle connection: ("https", search.nixos.org)
DEBUG reqwest::connect:625: starting new connection: https://search.nixos.org/
DEBUG reqwest::connect:501: proxy(http://127.0.0.1:7890) intercepts 'https://search.nixos.org/'
TRACE hyper_util::client::legacy::connect::http:481: Http::connect; scheme=Some("http"), host=Some("127.0.0.1"), port=Some(Port(7890))
DEBUG hyper_util::client::legacy::connect::http:769: connecting to 127.0.0.1:7890
DEBUG hyper_util::client::legacy::connect::http:772: connected to 127.0.0.1:7890
Something is intercepting your connection.
Something is intercepting your connection.
i have a http_proxy yes
The log message reads off like your proxy is redirecting the search endpoint to an invalid access. Please see if the command succeeds without the proxy enabled.