{"record":{"id":"fa8713600822c4ea","repo":"nats-io/nats-server","slug":"invalid-subject-queue-q","errorCode":null,"errorMessage":"invalid subject-queue %q","messagePattern":"invalid subject-queue %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/client.go","lineNumber":1084,"sourceCode":"\tif c.user == nil || !c.user.defaultPerms {\n\t\treturn false\n\t}\n\tif perms == nil {\n\t\tc.user.Permissions = nil\n\t\tc.perms = nil\n\t\tc.mperms = nil\n\t\tc.darray = nil\n\t\treturn true\n\t}\n\tc.user.Permissions = perms.clone()\n\tc.setPermissions(c.user.Permissions)\n\treturn true\n}\n\nfunc splitSubjectQueue(sq string) ([]byte, []byte, error) {\n\tvals := strings.Fields(strings.TrimSpace(sq))\n\tif len(vals) == 0 {\n\t\treturn nil, nil, fmt.Errorf(\"invalid subject-queue %q\", sq)\n\t}\n\ts := []byte(vals[0])\n\tvar q []byte\n\tif len(vals) == 2 {\n\t\tq = []byte(vals[1])\n\t} else if len(vals) > 2 {\n\t\treturn nil, nil, fmt.Errorf(\"invalid subject-queue %q\", sq)\n\t}\n\tif !IsValidSubject(vals[0]) || (len(q) > 0 && !IsValidSubject(vals[1])) {\n\t\treturn nil, nil, fmt.Errorf(\"invalid subject-queue %q\", sq)\n\t}\n\treturn s, q, nil\n}\n\n// Initializes client.perms structure.\n// Lock is held on entry.\nfunc (c *client) setPermissions(perms *Permissions) {\n\tif perms == nil {","sourceCodeStart":1066,"sourceCodeEnd":1102,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/client.go#L1066-L1102","documentation":"splitSubjectQueue was given an empty or whitespace-only string for the subject-queue parameter (used when a client sends a deliver-subject/queue style subscription spec, e.g. as part of queue subscription permissions or $JS API consumption of '<subject> <queue>'). After splitting on whitespace there are zero tokens, so the function cannot produce a subject and returns this error.","triggerScenarios":"Calling splitSubjectQueue (from subject/queue parsing in client.go) with sq == \"\" or a string containing only spaces/tabs, e.g. an empty token supplied where '<subject> [<queue>]' is expected.","commonSituations":"A client library or operator config sends an empty subject field; a subscription request with an all-whitespace subject; automation tooling that interpolates an unset variable into the subject position.","solutions":["Supply a non-empty, valid NATS subject as the first token of the string.","Check the client/request producing the empty value (config field, variable interpolation) and default or reject it before sending.","If queue subscription is intended, format as '<subject> <queue>' with exactly two whitespace-separated tokens."],"exampleFix":"// before\ncfg.Subject = \"\"\n// after\ncfg.Subject = \"orders.>\" // must be a non-empty valid subject","handlingStrategy":"validation","validationCode":"func validSubjectQueue(sq string) bool {\n    f := strings.Fields(strings.TrimSpace(sq))\n    return len(f) >= 1 && len(f) <= 2\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never interpolate possibly-empty variables into subject strings.","Trim and validate input before sending subscription requests.","Prefer official NATS client APIs over manual protocol strings."],"tags":["nats","subject","validation"],"backgroundTag":"invalid-subject-syntax","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}