{"record":{"id":"2f40a8d723eeae19","repo":"nats-io/nats-server","slug":"could-not-fetch-q-no-response","errorCode":null,"errorMessage":"could not fetch <%q>: no response","messagePattern":"could not fetch <%q>: no response","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/accounts.go","lineNumber":4251,"sourceCode":"\t\tMaxIdleConns:    10,\n\t\tIdleConnTimeout: 30 * time.Second,\n\t}\n\tur := &URLAccResolver{\n\t\turl: url,\n\t\tc:   &http.Client{Timeout: DEFAULT_ACCOUNT_FETCH_TIMEOUT, Transport: tr},\n\t}\n\treturn ur, nil\n}\n\n// Fetch will fetch the account jwt claims from the base url, appending the\n// account name onto the end.\nfunc (ur *URLAccResolver) Fetch(name string) (string, error) {\n\turl := ur.url + name\n\tresp, err := ur.c.Get(url)\n\tif err != nil {\n\t\treturn _EMPTY_, fmt.Errorf(\"could not fetch <%q>: %v\", redactURLString(url), err)\n\t} else if resp == nil {\n\t\treturn _EMPTY_, fmt.Errorf(\"could not fetch <%q>: no response\", redactURLString(url))\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn _EMPTY_, fmt.Errorf(\"could not fetch <%q>: %v\", redactURLString(url), resp.Status)\n\t}\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn _EMPTY_, err\n\t}\n\treturn string(body), nil\n}\n\n// Resolver based on nats for synchronization and backing directory for storage.\ntype DirAccResolver struct {\n\t*DirJWTStore\n\t*Server\n\tsyncInterval time.Duration\n\tfetchTimeout time.Duration","sourceCodeStart":4233,"sourceCodeEnd":4269,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/accounts.go#L4233-L4269","documentation":"URLAccResolver.Fetch treats a nil HTTP response with no error as a fatal anomaly. http.Client.Get normally returns either err or a response; a nil response with nil err is unexpected, so the resolver reports it as 'could not fetch <url>: no response'.","triggerScenarios":"Calling Fetch when ur.c.Get returns (nil, nil) — a pathological client/transport state, e.g. a custom HTTP client or RoundTripper misbehaving.","commonSituations":"Custom HTTP client injected into URLAccResolver (NewURLAccResolver with custom client) whose transport violates the net/http contract; heavily customized/proxied transports.","solutions":["Use the default http.Client or a correctly-behaving transport for the resolver","Inspect any custom RoundTripper for paths that return nil response and nil error","Log and restart/reconnect if a transient transport corruption is suspected"],"exampleFix":"// before\nur, err := NewURLAccResolver(url) // replaced client with custom transport returning nil,nil\n// after\nur, err := NewURLAccResolver(url) // keep default client, or fix RoundTripper to always return non-nil resp with err","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"jwt, err := fetchAccount(resolver, key)\nif err != nil && strings.Contains(err.Error(), \"no response\") {\n    // replace/recreate the resolver client; use fallback resolver\n}\n","preventionTips":["Avoid custom RoundTrippers that can return (nil, nil)","Keep the default http.Client unless transport behavior is well tested","Alert on this error: it indicates a broken HTTP client/transport"],"tags":["nats-server","http","account-resolver"],"backgroundTag":"empty-http-response","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}