{"record":{"id":"71b22fa8b1f85955","repo":"crowdsecurity/crowdsec","slug":"querying-range-w","errorCode":null,"errorMessage":"querying range: %w","messagePattern":"querying range: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/loki/internal/lokiclient/loki_client.go","lineNumber":189,"sourceCode":"\t\t\t\tclose(c)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tif len(lq.Data.Result) > 0 {\n\t\t\t\tlc.Logger.Debugf(\"(timer:%v) %d results / %d entries result[0] (uri:%s)\", lc.currentTickerInterval, len(lq.Data.Result), len(lq.Data.Result[0].Entries), uri)\n\t\t\t} else {\n\t\t\t\tlc.Logger.Debugf(\"(timer:%v) no results (uri:%s)\", lc.currentTickerInterval, uri)\n\t\t\t}\n\t\t\tif infinite {\n\t\t\t\tif len(lq.Data.Result) > 0 { //as long as we get results, we keep lowest ticker\n\t\t\t\t\tlc.decreaseTicker(ticker)\n\t\t\t\t} else {\n\t\t\t\t\tlc.increaseTicker(ticker)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\turi, err = updateURI(uri, lq, infinite)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"querying range: %w\", err)\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc (lc *LokiClient) getURLFor(endpoint string, params map[string]string) string {\n\tu, err := url.Parse(lc.config.LokiURL)\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\tqueryParams := u.Query()\n\tfor k, v := range params {\n\t\tqueryParams.Set(k, v)\n\t}\n\tu.RawQuery = queryParams.Encode()\n\n\tu.Path, err = url.JoinPath(lc.config.LokiPrefix, u.Path, endpoint)\n\tif err != nil {","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/loki/internal/lokiclient/loki_client.go#L171-L207","documentation":"After each successful poll, queryRange calls updateURI to compute the next pagination URI from the received timestamps. A failure there (url.Parse failure on the stored URI) is wrapped as 'querying range' and terminates the datasource.","triggerScenarios":"updateURI returns invalid Loki URL (error 464) during pagination — malformed base URI in config propagates through the polling loop.","commonSituations":"Same root causes as invalid Loki URL: badly formed DSN URL, unencoded special characters.","solutions":["Fix the DSN URL so it parses as a valid URL","Percent-encode special characters in query parameters","Test the exact URL with curl before putting it in acquis.yaml"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if _, err := url.Parse(dsnURL); err != nil {\n    return fmt.Errorf(\"fix DSN URL before starting datasource: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if _, err := updateURI(uri, lq, infinite); err != nil {\n    log.Errorf(\"pagination broke after %s: %v\", uri, err)\n    // restart the polling loop from the base URL instead of exiting\n}","preventionTips":["Keep the base URL simple and fully encoded","Re-test DSN URLs after any proxy or ingress change"],"tags":["loki","url","pagination"],"backgroundTag":"invalid-url-format","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}