{"record":{"id":"c34829478990a7b0","repo":"jaegertracing/jaeger","slug":"wrong-number-of-arguments","errorCode":null,"errorMessage":"wrong number of arguments","messagePattern":"wrong number of arguments","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/es-index-cleaner/main.go","lineNumber":58,"sourceCode":"\t\t\tfeaturegate.WithRegisterFromVersion(\"v2.5.0\"),\n\t\t\tfeaturegate.WithRegisterDescription(\"Deprecated alias for jaeger.es.index.relativeTimeIndexDeletion.\"),\n\t\t\tfeaturegate.WithRegisterReferenceURL(\"https://github.com/jaegertracing/jaeger/issues/9016\"),\n\t\t),\n\t)\n}\n\nfunc main() {\n\tlogger, _ := zap.NewProduction()\n\tv := viper.New()\n\tcfg := &app.Config{}\n\n\tcommand := &cobra.Command{\n\t\tUse:   \"jaeger-es-index-cleaner NUM_OF_DAYS http://HOSTNAME:PORT\",\n\t\tShort: \"Jaeger es-index-cleaner removes Jaeger indices\",\n\t\tLong:  \"Jaeger es-index-cleaner removes Jaeger indices\",\n\t\tRunE: func(_ *cobra.Command, args []string) error {\n\t\t\tif len(args) != 2 {\n\t\t\t\treturn errors.New(\"wrong number of arguments\")\n\t\t\t}\n\t\t\tnumOfDays, err := strconv.Atoi(args[0])\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"could not parse NUM_OF_DAYS argument: %w\", err)\n\t\t\t}\n\n\t\t\tif err := cfg.InitFromViper(v); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to initialize config: %w\", err)\n\t\t\t}\n\n\t\t\tctx := context.Background()\n\t\t\tesClient, err := app.NewESClient(ctx, args[1], cfg, logger)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error creating Elasticsearch client: %w\", err)\n\t\t\t}\n\t\t\ti := esclient.IndicesClient{\n\t\t\t\tClient:                 esClient,\n\t\t\t\tMasterTimeoutSeconds:   cfg.MasterNodeTimeoutSeconds,","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/cmd/es-index-cleaner/main.go#L40-L76","documentation":"refArg extracts a single span-field reference operand from a predicate call. If the predicate's sole argument is not a reference to a value on the span (asReference fails), the predicate is rejected with tracestore.ErrFilterInvalid because the operator semantically requires reading a field from the span. The error wraps ErrFilterInvalid so callers can distinguish malformed filters from unsupported ones.","triggerScenarios":"Calling a trace search with a filter predicate like tag(...) or a field-reading operator whose argument is a constant or another expression instead of a span field reference, detected in buildFilterQuery via refArg.","commonSituations":"Writing exists(\"production\") style filters where a constant is passed where a field/tag name reference is expected; programmatically constructed expression trees passing literal values; typos in filter DSL usage.","solutions":["Pass a span field reference (e.g. an attribute/tag reference) as the predicate's single argument, not a literal constant.","Finalize/validate the expression tree so constants are converted to references where the operator requires one.","Inspect the predicate's arguments before submitting: exactly one reference argument is required."],"exampleFix":"// before\n{\"op\": \"tag\", \"args\": [\"production\"]}\n// after\n{\"op\": \"tag\", \"args\": {\"ref\": \"tag.production\"}}","handlingStrategy":"validation","validationCode":"func singleRefArg(c *expression.Call) bool {\n    return len(c.Args) == 1 && isReference(c.Args[0])\n}","typeGuard":"func isReference(term expression.Expression) bool {\n    _, ok := asReference(term)\n    return ok\n}","tryCatchPattern":"ref, err := refArg(predicate)\nif errors.Is(err, tracestore.ErrFilterInvalid) {\n    // predicate needs a span-field reference argument\n}","preventionTips":["Pass field/tag references, not literals, to ref-reading operators.","Finalize expression trees so constants become references where required.","Validate predicate argument shapes client-side before submission."],"tags":["query-filter","invalid-argument","expression"],"backgroundTag":"invalid-filter-argument","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}