{"record":{"id":"f92c0a4eac62619b","repo":"dgraph-io/dgraph","slug":"value-for-predicate-dgraph-rule-permission-shoul","errorCode":null,"errorMessage":"Value for predicate <dgraph.rule.permission> should be of type int","messagePattern":"Value for predicate <dgraph\\.rule\\.permission> should be of type int","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"worker/mutation.go","lineNumber":577,"sourceCode":"\t)\n\n\tsrc := types.Val{Tid: types.TypeID(edge.ValueType), Value: edge.Value}\n\t// check compatibility of schema type and storage type\n\t// The goal is to convert value on edge to value type defined by schema.\n\tif dst, err = types.Convert(src, schemaType); err != nil {\n\t\treturn err\n\t}\n\n\t// convert to schema type\n\tb := types.ValueForType(types.BinaryID)\n\tif err = types.Marshal(dst, &b); err != nil {\n\t\treturn err\n\t}\n\n\tif x.WorkerConfig.AclEnabled && x.ParseAttr(edge.GetAttr()) == \"dgraph.rule.permission\" {\n\t\tperm, ok := dst.Value.(int64)\n\t\tif !ok {\n\t\t\treturn errors.Errorf(\"Value for predicate <dgraph.rule.permission> should be of type int\")\n\t\t}\n\t\tif perm < 0 || perm > 7 {\n\t\t\treturn errors.Errorf(\"Can't set <dgraph.rule.permission> to %d, Value for this\"+\n\t\t\t\t\" predicate should be between 0 and 7\", perm)\n\t\t}\n\t}\n\n\t// TODO: Figure out why this is Enum. It really seems like an odd choice -- rather than\n\t//       specifying it as the same type as presented in su.\n\tedge.ValueType = schemaType.Enum()\n\tvar ok bool\n\tedge.Value, ok = b.Value.([]byte)\n\tif !ok {\n\t\treturn errors.Errorf(\"failure to convert edge type: '%+v' to schema type: '%+v'\",\n\t\t\tstorageType, schemaType)\n\t}\n\n\treturn nil","sourceCodeStart":559,"sourceCodeEnd":595,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/mutation.go#L559-L595","documentation":"When ACLs are enabled, the internal predicate dgraph.rule.permission stores a permission bitmask (0-7) per (group, predicate) rule. ValidateAndConvert checks every mutation of this predicate and rejects it if the converted value is not an int64, since only integers form a valid permission mask.","triggerScenarios":"A mutation (executed via runMutation -> proposeAndWait, typically through the ACL APIs or @group directives) sets dgraph.rule.permission to a non-int value, e.g. a float, string, or bool because the value was sent as \"5\" (string) or 5.0 (float) in JSON.","commonSituations":"Automation scripts that read ACL rules from JSON/YAML where numbers deserialize as float or string; hand-written JSON mutations that quote the number; ACL tooling bugs.","solutions":["Send the permission as an integer, e.g. {\"set\":[{\"uid\":\"0x...\",\"dgraph.rule.permission\":5}]}.","Convert string/float values to int64 before submitting the ACL mutation (e.g. int(value) in the script).","Confirm ACL is truly enabled (x.WorkerConfig.AclEnabled); if you did not intend to touch ACL internals, use the intended predicate instead."],"exampleFix":"// before (fails)\n{\"set\":[{\"uid\":\"0x1\",\"dgraph.rule.permission\":\"5\"}]}\n\n// after\n{\"set\":[{\"uid\":\"0x1\",\"dgraph.rule.permission\":5}]}","handlingStrategy":"type-guard","validationCode":"function assertAclPermissionInt(value) {\n  if (!Number.isInteger(value)) {\n    throw new TypeError(`dgraph.rule.permission must be an integer, got ${typeof value}: ${value}`)\n  }\n}","typeGuard":"function isInt64(v) {\n  return typeof v === 'number' && Number.isInteger(v) && v >= Number.MIN_SAFE_INTEGER && v <= Number.MAX_SAFE_INTEGER\n}","tryCatchPattern":"try {\n  await aclClient.modifyPermissions(rule)\n} catch (e) {\n  if (String(e).includes('should be of type int')) {\n    // coerce to int and re-submit\n  }\n}","preventionTips":["Never quote numeric permission values in JSON mutations.","Parse ACL config files with integer-typed fields (avoid YAML/JSON float coercion).","Wrap ACL mutations in helper functions that validate input types."],"tags":["dgraph","acl","type-mismatch"],"backgroundTag":"acl-permission-type-invalid","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}