{"record":{"id":"d65d27d1c7865ca4","repo":"semaphoreui/semaphore","slug":"invalid-format-of-arguments-must-be-valid-json-ar","errorCode":null,"errorMessage":"invalid format of arguments, must be valid JSON array or map: %v","messagePattern":"invalid format of arguments, must be valid JSON array or map: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"services/tasks/local_executor.go","lineNumber":674,"sourceCode":"func convertArgsJSONIfArray(argsJSON string) (map[string][]string, error) {\n\tif argsJSON == \"\" {\n\t\treturn nil, nil\n\t}\n\n\t// Try to parse as array first\n\tvar arr []string\n\tif err := json.Unmarshal([]byte(argsJSON), &arr); err == nil {\n\t\t// It's an array, convert to map format\n\t\tmapArgs := map[string][]string{\n\t\t\t\"default\": arr,\n\t\t}\n\t\treturn mapArgs, nil\n\t}\n\n\t// If not an array, verify it's a valid map format\n\tvar mapArgs map[string][]string\n\tif err := json.Unmarshal([]byte(argsJSON), &mapArgs); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid format of arguments, must be valid JSON array or map: %v\", err)\n\t}\n\n\treturn mapArgs, nil\n}\n\n// getCLIArgsMap returns args that support both array and map formats\n// Array format is automatically converted to map with \"default\" key for backward compatibility\n// Returns: templateArgsMap (map), taskArgsMap (map), err\nfunc (t *LocalExecutor) getCLIArgsMap() (templateArgsMap map[string][]string, taskArgsMap map[string][]string, err error) {\n\n\t// Convert template arguments if needed\n\tif t.Template.Arguments != nil {\n\t\ttemplateArgsMap, err = convertArgsJSONIfArray(*t.Template.Arguments)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t}\n","sourceCodeStart":656,"sourceCodeEnd":692,"githubUrl":"https://github.com/semaphoreui/semaphore/blob/1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa/services/tasks/local_executor.go#L656-L692","documentation":"Returned by convertArgsJSONIfArray in services/tasks/local_executor.go when the arguments JSON string is neither a JSON array of strings nor a JSON object of the shape map[string][]string. The function first tries to unmarshal as []string, then as the map form; failing both means the input does not match either accepted schema (mixed types, object values that are not string arrays, or syntactically invalid JSON). The %v embeds the last unmarshal error showing why the map parse failed.","triggerScenarios":"Thrown at services/tasks/local_executor.go:674 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a plain JSON string array like [\"arg1\",\"arg2\"] or a named-arguments object like {\"default\":[\"arg1\"],\"env\":[\"x=1\"]}","Ensure every value in the object form is itself an array of strings, not a bare string or number","Paste the arguments into a JSON validator to find the syntax error (quotes, commas, brackets)","Fix or normalise the stored arguments string, then retry the task"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa","analyzedAt":"2026-09-07T11:00:33.293Z","contentChangedAt":"2026-09-07T11:00:33.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}