multica-ai/multica · error

--ref is not valid JSON: %w

Error message

--ref is not valid JSON: %w

What it means

Error "--ref is not valid JSON: %w" thrown in multica-ai/multica.

Source

Thrown at server/cmd/multica/cmd_project.go:771

}

func buildResourceRefFromRefFlag(cmd *cobra.Command, resourceType string, existingRef map[string]any) (any, bool, error) {
	if !cmd.Flags().Changed("ref") {
		return nil, false, nil
	}
	rawRef, _ := cmd.Flags().GetString("ref")
	rawRef = strings.TrimSpace(rawRef)
	// --ref is the generic JSON resource_ref escape hatch. For github_repo it
	// does double duty: a JSON object/array ("{...}" / "[...]") is still the
	// escape hatch, but any other value — including bare scalars like a numeric
	// tag ("2024") or an all-digit short SHA ("1234567") — is a checkout-ref
	// shortcut that merges with --url. Only parse JSON when the value is
	// actually meant as JSON; otherwise json.Unmarshal would accept "2024" as a
	// number and silently swallow a legitimate checkout ref.
	if rawRef != "" && (resourceType != "github_repo" || looksLikeJSONPayload(rawRef)) {
		var ref any
		if err := json.Unmarshal([]byte(rawRef), &ref); err != nil {
			return nil, false, fmt.Errorf("--ref is not valid JSON: %w", err)
		}
		return ref, true, nil
	}
	if resourceType != "github_repo" {
		return nil, false, fmt.Errorf("--ref must be a JSON resource_ref payload for resource type %q", resourceType)
	}
	ref, has, err := buildResourceRefFromFlags(cmd, resourceType, existingRef)
	if err != nil {
		return nil, false, err
	}
	return ref, has, nil
}

func looksLikeJSONPayload(raw string) bool {
	raw = strings.TrimSpace(raw)
	return strings.HasPrefix(raw, "{") || strings.HasPrefix(raw, "[")
}

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Fix the --ref value so it is valid JSON.

When it happens

Trigger: Thrown at server/cmd/multica/cmd_project.go:771 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/9f9a66210da92b07. Report an issue: GitHub.