v2rayA/v2rayA · warning
invalid query
Error message
invalid query
What it means
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).
Source
Thrown at service/server/controller/logger.go:22
"bufio"
"errors"
"io"
"os"
"github.com/gin-gonic/gin"
"github.com/v2rayA/v2rayA/common"
"github.com/v2rayA/v2rayA/conf"
)
type getLogQuery struct {
Skip int64 `json:"skip" form:"skip"`
}
func GetLogger(ctx *gin.Context) {
config := conf.GetEnvironmentConfig()
query := getLogQuery{}
if ctx.ShouldBindQuery(&query) != nil {
common.ResponseError(ctx, errors.New("invalid query"))
return
}
if config.LogFile == "" {
if query.Skip == 0 {
ctx.String(200, "log printed to console, please see log in console.")
} else {
ctx.String(200, "")
}
return
}
f, err := os.Open(config.LogFile)
if err != nil {
common.ResponseError(ctx, logError(err))
return
}
defer f.Close()
_, err = f.Seek(query.Skip, io.SeekStart)
if err != nil {View on GitHub (pinned to 71e5442fc5)
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
Example fix
// before: non-integer skip causes bind failure GET /api/log?skip=12ab // after GET /api/log?skip=12288
Defensive patterns
Strategy: validation
Validate before calling
func buildLogURL(base string, skip int64) string {
if skip < 0 { skip = 0 }
return fmt.Sprintf("%s?skip=%d", base, skip)
} Try / catch
resp, err := http.Get(url)
if err == nil && strings.Contains(readBody(resp), "invalid query") {
// retry once without the skip parameter
resp, err = http.Get(baseURL)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid query parameter" / "Failed to parse value of ...": fixing bad query string parameters across APIs — this error's family across 36 libraries.
Related errors
AI-assisted analysis of v2rayA/v2rayA@71e5442fc5 (2026-09-05).
Data as JSON: /api/errors/5d3b25b495c650a8.
Report an issue: GitHub.