{"record":{"id":"535d91c22c4485e5","repo":"multica-ai/multica","slug":"s-must-be-valid-utf-8","errorCode":null,"errorMessage":"%s must be valid UTF-8","messagePattern":"(.+?) must be valid UTF-8","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_skill.go","lineNumber":226,"sourceCode":"\tif filePath != \"\" {\n\t\tdata, err := os.ReadFile(filePath)\n\t\tif err != nil {\n\t\t\treturn \"\", false, fmt.Errorf(\"read file for --content-file: %w\", err)\n\t\t}\n\t\treturn skillContentBytesToString(data, \"file content for --content-file\")\n\t}\n\tif inlineSet {\n\t\treturn inline, true, nil\n\t}\n\treturn \"\", false, nil\n}\n\nfunc skillContentBytesToString(data []byte, label string) (string, bool, error) {\n\tif len(data) == 0 {\n\t\treturn \"\", false, fmt.Errorf(\"%s is empty\", label)\n\t}\n\tif !utf8.Valid(data) {\n\t\treturn \"\", false, fmt.Errorf(\"%s must be valid UTF-8\", label)\n\t}\n\treturn string(data), true, nil\n}\n\nfunc runSkillList(cmd *cobra.Command, _ []string) error {\n\tclient, err := newAPIClient(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tctx, cancel := cli.APIContext(context.Background())\n\tdefer cancel()\n\n\tvar skills []map[string]any\n\tif err := client.GetJSON(ctx, \"/api/skills\", &skills); err != nil {\n\t\treturn fmt.Errorf(\"list skills: %w\", err)\n\t}\n","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_skill.go#L208-L244","documentation":"Content validation from skillContentBytesToString: the resolved bytes are not valid UTF-8. Skill content is transmitted as a JSON string to the API, so non-UTF-8 bytes (binary files, wrong-encoding text) cannot be carried and are rejected client-side before any network call. The label names the offending source.","triggerScenarios":"Passing a binary or Latin-1/CP1252-encoded file via --content-file, or piping compiled/binary output through --content-stdin.","commonSituations":"Assuming skill content can be any file type; text files saved in legacy encodings from Windows tools; accidentally pointing --content-file at an archive or image.","solutions":["Check the encoding: `file -i <path>`; convert with `iconv -f <src-encoding> -t UTF-8`.","If the payload is genuinely binary, it does not belong in skill content — store it elsewhere and reference it by path/URL.","Re-save the source file as UTF-8 in your editor before re-running the command."],"exampleFix":"# before\nmultica skill create --name s --content-file legacy-latin1.md\n# after\niconv -f ISO-8859-1 -t UTF-8 legacy-latin1.md > skill.utf8.md\nmultica skill create --name s --content-file skill.utf8.md","handlingStrategy":"validation","validationCode":"# Reject non-UTF-8 or binary input before the CLI\ncase \"$(file -b --mime-encoding \"$CONTENT_FILE\")\" in utf-8|us-ascii) ;; *) echo \"not UTF-8\"; exit 2;; esac\n# or in Go: if !utf8.Valid(data) { return errors.New(\"content must be UTF-8\") }","typeGuard":"func isValidSkillContent(data []byte) bool {\n    return len(data) > 0 && utf8.Valid(data)\n}","tryCatchPattern":"Match 'must be valid UTF-8'; convert encoding with iconv or exclude the binary payload, then retry — the raw bytes cannot be made valid by escaping.","preventionTips":["Save source files as UTF-8.","Never point content flags at binary assets; reference them by path instead.","Run `file -i` on suspect files in CI before skill publish steps."],"tags":["go","cli","validation","utf-8","encoding","skills"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}