{"record":{"id":"5b68388e9a0e2d1d","repo":"joewalnes/websocketd","slug":"socketmode-q-is-not-an-octal-permission-mode-e","errorCode":null,"errorMessage":"--socketmode %q is not an octal permission mode (e.g. 0700)","messagePattern":"--socketmode %q is not an octal permission mode \\(e\\.g\\. 0700\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config.go","lineNumber":90,"sourceCode":"\tfor _, o := range allowOrigins {\n\t\tif !strings.Contains(o, \"://\") {\n\t\t\tout = append(out, o)\n\t\t}\n\t}\n\treturn out\n}\n\n// parseSocketMode parses the --socketmode flag: an octal permission mode\n// such as \"0700\". The empty string means \"not set\" and leaves the socket\n// file to the process umask; an explicit zero is rejected because it would\n// make the socket unusable for everyone, owner included.\nfunc parseSocketMode(s string) (os.FileMode, error) {\n\tif s == \"\" {\n\t\treturn 0, nil\n\t}\n\tmode, err := strconv.ParseUint(s, 8, 32)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"--socketmode %q is not an octal permission mode (e.g. 0700)\", s)\n\t}\n\tif mode > 0o777 {\n\t\treturn 0, fmt.Errorf(\"--socketmode %q has bits beyond permission bits (keep it within 0777)\", s)\n\t}\n\tif mode == 0 {\n\t\treturn 0, fmt.Errorf(\"--socketmode 0 would make the socket unusable; pick a mode like 0700\")\n\t}\n\treturn os.FileMode(mode), nil\n}\n\n// resolveAddresses builds the list of TCP addresses to listen on.\nfunc resolveAddresses(addrlist []string, port int) []string {\n\tif len(addrlist) > 0 {\n\t\taddrs := make([]string, len(addrlist))\n\t\tfor i, addr := range addrlist {\n\t\t\taddrs[i] = fmt.Sprintf(\"%s:%d\", addr, port)\n\t\t}\n\t\treturn addrs","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/joewalnes/websocketd/blob/7a8683dc7f9778dc615945aaed2a8dc77290227b/config.go#L72-L108","documentation":"parseSocketMode validates the --socketmode flag value. The value must be a valid octal number; if strconv.ParseUint(s, 8, 32) fails, this error is returned so the operator knows the mode string is malformed.","triggerScenarios":"Running websocketd with --socketmode set to a string that is not a valid octal number, e.g. --socketmode=rwx or --socketmode=08 (8 is not an octal digit) or --socketmode=-1.","commonSituations":"Passing symbolic permissions like 'u=rwx' instead of numeric octal; copying a mode with a stray character or whitespace; assuming decimal input works.","solutions":["Pass a pure octal string, e.g. --socketmode 0700 or 600","Remove non-octal characters (8, 9, letters, quotes-in-shell artifacts)","Quote the value in the shell if it starts with 0 to avoid weird expansion"],"exampleFix":"// before\nwebsocketd --socketmode=rw --port=8080 ./script.sh\n// after\nwebsocketd --socketmode=0600 --port=8080 ./script.sh","handlingStrategy":"validation","validationCode":"const isOctal = (s) => /^[0-7]+$/.test(s) && parseInt(s, 8) <= 0o777;\nif (socketMode && !isOctal(socketMode)) throw new Error(`--socketmode ${socketMode} is not octal`);","typeGuard":"const isOctalMode = (s) => typeof s === 'string' && /^[0-7]+$/.test(s);","tryCatchPattern":"try { mode := parseSocketMode(flagValue) } catch { /* fall back to default 0700 and log */ }","preventionTips":["Always write modes as 3-4 octal digits with a leading 0 (0700)","Never use symbolic or decimal permission strings","Shell-quote values starting with 0"],"tags":["cli","config-validation","unix-permissions"],"backgroundTag":"invalid-octal-mode","analyzedSha":"7a8683dc7f9778dc615945aaed2a8dc77290227b","analyzedAt":"2026-09-03T13:52:22.309Z","contentChangedAt":"2026-09-03T13:52:22.309Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}