{"record":{"id":"c4483abbd4f89147","repo":"stride3d/stride","slug":"unable-to-parse-the-input-string","errorCode":null,"errorMessage":"Unable to parse the input string.","messagePattern":"Unable to parse the input string\\.","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/Reflection/ItemId.cs","lineNumber":57,"sourceCode":"    /// <summary>\n    /// Generates a new random <see cref=\"ItemId\"/>.\n    /// </summary>\n    /// <returns></returns>\n    public static ItemId New()\n    {\n        return new ItemId(ObjectId.New());\n    }\n\n    /// <summary>\n    /// Parses an <see cref=\"ItemId\"/> from a string.\n    /// </summary>\n    /// <param name=\"input\">The input string to parse.</param>\n    /// <returns>An <see cref=\"ItemId\"/> corresponding to the parsed string.</returns>\n    /// <exception cref=\"FormatException\">The given string cannot be parsed as an <see cref=\"ItemId\"/>.</exception>\n    public static ItemId Parse(string input)\n    {\n        if (!TryParse(input, out var itemId))\n            throw new FormatException(\"Unable to parse the input string.\");\n\n        return itemId;\n    }\n\n    /// <summary>\n    /// Attempts to parse an <see cref=\"ItemId\"/> from a string.\n    /// </summary>\n    /// <param name=\"input\">The input string to parse.</param>\n    /// <param name=\"itemId\">The resulting <see cref=\"ItemId\"/>.</param>\n    /// <returns>True if the string could be successfully parsed, False otherwise.</returns>\n    public static bool TryParse(string input, out ItemId itemId)\n    {\n        if (ObjectId.TryParse(input, out var objectId))\n        {\n            itemId = new ItemId(objectId);\n            return true;\n        }\n        itemId = Empty;","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/Reflection/ItemId.cs#L39-L75","documentation":"ItemId.Parse converts a string (typically a GUID in the canonical form produced by ItemId/ Guid) into an ItemId. It delegates to TryParse and, if parsing fails, throws FormatException. The library throws this when the input string is not a valid, fully-formed identifier.","triggerScenarios":"Calling ItemId.Parse with a null, empty, malformed, or non-GUID string — e.g. a truncated id, a string with braces/extra whitespace the parser does not accept, or user-supplied text instead of an id.","commonSituations":"Reading ids from configuration files or command-line arguments where the value was copied incorrectly; parsing ids from older asset files written in a different format; passing an empty string from an unset environment variable.","solutions":["Switch to ItemId.TryParse and handle the false return instead of catching FormatException.","Verify the input string is a valid GUID in the exact format the library emits (32 hex digits / 'N' or 'D' form) and trim whitespace.","Fix the source data (config, YAML asset, CLI arg) to contain the correct id string.","Regenerate the id with ItemId.New() if the original value is unrecoverable."],"exampleFix":"// before\nvar id = ItemId.Parse(userInput);\n\n// after\nif (!ItemId.TryParse(userInput?.Trim(), out var id))\n    throw new ArgumentException($\"'{userInput}' is not a valid ItemId\", nameof(userInput));","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(input) || !Guid.TryParseExact(input.Trim(), \"D\", out _))\n    throw new ArgumentException(\"Not a valid ItemId string\", nameof(input));\nvar id = ItemId.Parse(input.Trim());","typeGuard":"bool IsValidItemId(string? s) => !string.IsNullOrWhiteSpace(s) && Guid.TryParseExact(s.Trim(), \"D\", out _);","tryCatchPattern":"try { var id = ItemId.Parse(input); }\ncatch (FormatException) { /* fall back to ItemId.New() or surface a user error */ }","preventionTips":["Prefer ItemId.TryParse over Parse for external input","Trim and normalize id strings read from config or CLI","Regenerate ids instead of guessing at malformed ones","Validate asset files' id fields before load"],"tags":["parsing","guid","format","identifier"],"backgroundTag":"invalid-argument-format","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}