{"record":{"id":"8b37dce42b5f1ddd","repo":"Unity-Technologies/UnityCsReference","slug":"id-must-be-a-number-line-line","errorCode":null,"errorMessage":"Id must be a number (line: '{line}')","messagePattern":"Id must be a number \\(line: '(.+?)'\\)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Scripting/RestrictedApisValidation/RestrictedApisConfig.cs","lineNumber":177,"sourceCode":"        var signature = NextToken(ref lineSpan, out separatorIndex);\n        if (separatorIndex == -1)\n            throw new Exception($\"Invalid severity '' in line '{line}'\");\n\n        var severitySpan = NextToken(ref lineSpan, out separatorIndex);\n        var description = \"\";\n        var documentationUrl = \"\";\n        if (separatorIndex != -1)\n        {\n            description = NextToken(ref lineSpan,  out separatorIndex).ToString();\n            if (separatorIndex != -1)\n            {\n                documentationUrl = NextToken(ref lineSpan,  out separatorIndex).ToString();\n            }\n        }\n\n        if (!Int32.TryParse(id, out var intId))\n        {\n            throw new Exception($\"Id must be a number (line: '{line}')\");\n        }\n\n        int referenceHashCode;\n        var isTypeSignature = false;\n        if (signature.Length == 0)\n        {\n            if (!_idToSignatureDetails.TryGetValue(intId, out var previousMappedId))\n                throw new Exception($\"Id ({intId}) overriden in configuration line '{line}' is not defined by any previous lines.\");\n\n            (referenceHashCode, isTypeSignature)  = previousMappedId;\n        }\n        else\n        {\n            isTypeSignature = line.AsSpan().IndexOf(\"::\") == -1; // member signatures must have a :: as a declaring type name/member name separator\n\n            //TODO: When we switch from netstandard to *any* .NET BCL, remove the ToString() and call String.GetHashCode(signature) : https://learn.microsoft.com/en-us/dotnet/api/system.string.gethashcode?view=net-9.0#system-string-gethashcode(system-readonlyspan((system-char)))\n            referenceHashCode = signature.ToString().GetHashCode();\n            _idToSignatureDetails[intId] = new (referenceHashCode, isTypeSignature);","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Scripting/RestrictedApisValidation/RestrictedApisConfig.cs#L159-L195","documentation":"Thrown when the rule id (the text after ':' up to the first '|') cannot be parsed as an Int32. Restricted API rule ids must be numeric so they can be used as dictionary keys and for override matching.","triggerScenarios":"A rule line whose ':id' token is non-numeric, e.g. ':abc | signature | error'.","commonSituations":"Using a string/label as an id, typos, or copy-paste from a non-numeric identifier scheme.","solutions":["Change the id to an integer, e.g. ':1001 | signature | error'.","Ensure ids are unique and numeric across the file."],"exampleFix":"// before\n:FILE_OPEN | System.IO.File::Open | error\n// after\n:1001 | System.IO.File::Open | error","handlingStrategy":"validation","validationCode":"// Rule ids must be integers.\nvar id = token.Slice(1); // after ':'\nif (!Int32.TryParse(id, out _))\n    throw new FormatException($\"Rule id is not a number: '{line}'\");","typeGuard":null,"tryCatchPattern":"try { config = RestrictedApisConfig.Load(path); }\ncatch (Exception ex) when (ex.Message.Contains(\"Id must be a number\"))\n{ /* replace the non-numeric id with an integer */ }","preventionTips":["Use numeric ids consistently; track them in a registry to stay unique.","Avoid string/label ids when authoring rules."],"tags":["config","restricted-apis","validation","parsing"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}