{"record":{"id":"5d3b25b495c650a8","repo":"v2rayA/v2rayA","slug":"invalid-query","errorCode":null,"errorMessage":"invalid query","messagePattern":"invalid query","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"service/server/controller/logger.go","lineNumber":22,"sourceCode":"\t\"bufio\"\n\t\"errors\"\n\t\"io\"\n\t\"os\"\n\n\t\"github.com/gin-gonic/gin\"\n\t\"github.com/v2rayA/v2rayA/common\"\n\t\"github.com/v2rayA/v2rayA/conf\"\n)\n\ntype getLogQuery struct {\n\tSkip int64 `json:\"skip\" form:\"skip\"`\n}\n\nfunc GetLogger(ctx *gin.Context) {\n\tconfig := conf.GetEnvironmentConfig()\n\tquery := getLogQuery{}\n\tif ctx.ShouldBindQuery(&query) != nil {\n\t\tcommon.ResponseError(ctx, errors.New(\"invalid query\"))\n\t\treturn\n\t}\n\tif config.LogFile == \"\" {\n\t\tif query.Skip == 0 {\n\t\t\tctx.String(200, \"log printed to console, please see log in console.\")\n\t\t} else {\n\t\t\tctx.String(200, \"\")\n\t\t}\n\t\treturn\n\t}\n\tf, err := os.Open(config.LogFile)\n\tif err != nil {\n\t\tcommon.ResponseError(ctx, logError(err))\n\t\treturn\n\t}\n\tdefer f.Close()\n\t_, err = f.Seek(query.Skip, io.SeekStart)\n\tif err != nil {","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/v2rayA/v2rayA/blob/71e5442fc548c05680ee55eae943e6c0afe9ac51/service/server/controller/logger.go#L4-L40","documentation":"GetLogger (service/server/controller/logger.go:18-24) binds the request's query string into getLogQuery{Skip int64 `form:\"skip\"`} using gin's ShouldBindQuery. If binding fails, it responds 'invalid query' without aborting. Binding fails when the 'skip' parameter is present but not a valid integer (or violates the form binding rules).","triggerScenarios":"GET request to the log endpoint with ?skip=abc, ?skip=1.5, ?skip=999999999999999999999 (int64 overflow), or another non-integer value for skip; ShouldBindQuery returns non-nil at logger.go:21.","commonSituations":"Clients paging through logs with a hand-built query string passing garbage in skip; copy-pasted URLs with URL-encoding issues; scripts treating skip as an offset in bytes with wrong types.","solutions":["Send ?skip=<non-negative integer> (e.g. ?skip=1024) or omit skip entirely (defaults to 0)","Check the client code that builds the query string for type errors (string vs int)","URL-encode the parameter correctly if constructed manually"],"exampleFix":"// before: non-integer skip causes bind failure\nGET /api/log?skip=12ab\n// after\nGET /api/log?skip=12288","handlingStrategy":"validation","validationCode":"func buildLogURL(base string, skip int64) string {\n    if skip < 0 { skip = 0 }\n    return fmt.Sprintf(\"%s?skip=%d\", base, skip)\n}","typeGuard":null,"tryCatchPattern":"resp, err := http.Get(url)\nif err == nil && strings.Contains(readBody(resp), \"invalid query\") {\n    // retry once without the skip parameter\n    resp, err = http.Get(baseURL)\n}","preventionTips":["Always serialize skip from an integer type, never string concatenation of user input","Omit skip entirely when you want offset 0","Clamp skip to >= 0 and within int64 range before sending","Test query-building code with the log endpoint using non-trivial offsets"],"tags":["gin","go","http","query-params"],"backgroundTag":"invalid-query-parameter","analyzedSha":"71e5442fc548c05680ee55eae943e6c0afe9ac51","analyzedAt":"2026-09-05T20:04:37.459Z","contentChangedAt":"2026-09-05T20:04:37.459Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}