{"record":{"id":"9f9a66210da92b07","repo":"multica-ai/multica","slug":"ref-is-not-valid-json-w","errorCode":null,"errorMessage":"--ref is not valid JSON: %w","messagePattern":"--ref is not valid JSON: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_project.go","lineNumber":771,"sourceCode":"}\n\nfunc buildResourceRefFromRefFlag(cmd *cobra.Command, resourceType string, existingRef map[string]any) (any, bool, error) {\n\tif !cmd.Flags().Changed(\"ref\") {\n\t\treturn nil, false, nil\n\t}\n\trawRef, _ := cmd.Flags().GetString(\"ref\")\n\trawRef = strings.TrimSpace(rawRef)\n\t// --ref is the generic JSON resource_ref escape hatch. For github_repo it\n\t// does double duty: a JSON object/array (\"{...}\" / \"[...]\") is still the\n\t// escape hatch, but any other value — including bare scalars like a numeric\n\t// tag (\"2024\") or an all-digit short SHA (\"1234567\") — is a checkout-ref\n\t// shortcut that merges with --url. Only parse JSON when the value is\n\t// actually meant as JSON; otherwise json.Unmarshal would accept \"2024\" as a\n\t// number and silently swallow a legitimate checkout ref.\n\tif rawRef != \"\" && (resourceType != \"github_repo\" || looksLikeJSONPayload(rawRef)) {\n\t\tvar ref any\n\t\tif err := json.Unmarshal([]byte(rawRef), &ref); err != nil {\n\t\t\treturn nil, false, fmt.Errorf(\"--ref is not valid JSON: %w\", err)\n\t\t}\n\t\treturn ref, true, nil\n\t}\n\tif resourceType != \"github_repo\" {\n\t\treturn nil, false, fmt.Errorf(\"--ref must be a JSON resource_ref payload for resource type %q\", resourceType)\n\t}\n\tref, has, err := buildResourceRefFromFlags(cmd, resourceType, existingRef)\n\tif err != nil {\n\t\treturn nil, false, err\n\t}\n\treturn ref, has, nil\n}\n\nfunc looksLikeJSONPayload(raw string) bool {\n\traw = strings.TrimSpace(raw)\n\treturn strings.HasPrefix(raw, \"{\") || strings.HasPrefix(raw, \"[\")\n}\n","sourceCodeStart":753,"sourceCodeEnd":789,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_project.go#L753-L789","documentation":"Error \"--ref is not valid JSON: %w\" thrown in multica-ai/multica.","triggerScenarios":"Thrown at server/cmd/multica/cmd_project.go:771 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the --ref value so it is valid JSON."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}