{"record":{"id":"43f92e1836b30d45","repo":"SigNoz/signoz","slug":"errcoderoleinvalidinput-43f92e","errorCode":"ErrCodeRoleInvalidInput","errorMessage":"transactionGroups must be an array of {relation, objectGroup} objects","messagePattern":"transactionGroups must be an array of (.+?) objects","errorType":"validation","errorClass":"errors SigNozError","httpStatus":400,"severity":"error","filePath":"pkg/types/authtypes/transaction.go","lineNumber":59,"sourceCode":"}\n\ntype TransactionWithAuthorization struct {\n\tTransaction *Transaction\n\tAuthorized  bool\n}\n\nfunc NewTransaction(relation Relation, object coretypes.Object) (*Transaction, error) {\n\tif err := coretypes.ErrIfVerbNotValidForResource(relation.Verb, object.Resource); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Transaction{ID: valuer.GenerateUUID(), Relation: relation, Object: object}, nil\n}\n\nfunc NewTransactionGroups(data []byte) (TransactionGroups, error) {\n\tvar rawGroups []rawTransactionGroup\n\tif err := json.Unmarshal(data, &rawGroups); err != nil {\n\t\treturn nil, errors.New(errors.TypeInvalidInput, ErrCodeRoleInvalidInput, \"transactionGroups must be an array of {relation, objectGroup} objects\")\n\t}\n\n\tgroups := make(TransactionGroups, 0, len(rawGroups))\n\tfor index, rawGroup := range rawGroups {\n\t\tgroup, err := newTransactionGroup(rawGroup, index)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tgroups = append(groups, group)\n\t}\n\n\treturn groups, nil\n}\n\nfunc NewTransactionGroupsFromTransactions(transactions []coretypes.Transaction) TransactionGroups {\n\tobjectsByVerb := make(map[string][]*coretypes.Object)\n\tfor _, transaction := range transactions {","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/types/authtypes/transaction.go#L41-L77","documentation":"Thrown by NewTransactionGroups when the JSON payload for transactionGroups cannot be unmarshalled into an array of {relation, objectGroup} objects. The data must be a JSON array where each element has a valid relation and objectGroup. It wraps the underlying json.Unmarshal failure on malformed structure.","triggerScenarios":"Calling UnmarshalJSON/Scan on a Transaction-bearing type where transactionGroups is a JSON object instead of an array, an array of scalars, or elements missing/wrong-typed relation/objectGroup fields; also DB Scan of a corrupt column value.","commonSituations":"Hand-written JSON payloads in tests, API clients sending a single group object instead of an array, schema drift between stored JSON and the Go type after upgrades.","solutions":["Verify the payload is a JSON array: [{\"relation\":\"...\",\"objectGroup\":{...}}]","Ensure each element has both relation and objectGroup present with correct types","If reading from DB, check the stored column for truncated or legacy-format JSON","Add unit test unmarshalling the exact payload you send"],"exampleFix":"// before\n{\"transactionGroups\":{\"relation\":\"reader\"}}\n// after\n{\"transactionGroups\":[{\"relation\":\"reader\",\"objectGroup\":{\"...\":{}}}]}\n","handlingStrategy":"validation","validationCode":"func isValidTransactionGroups(data []byte) bool {\n    var raw []map[string]json.RawMessage\n    return json.Unmarshal(data, &raw) == nil\n}","typeGuard":null,"tryCatchPattern":"if _, err := authtypes.NewTransactionGroups(body); err != nil { return http.StatusBadRequest }","preventionTips":["Validate array structure client-side before submit","Keep a golden JSON fixture in tests for transactionGroups"],"tags":["json","validation","authorization","go"],"backgroundTag":"json-unmarshal-type-mismatch","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}