{"record":{"id":"befeb03bee825d7f","repo":"EllanJiang/GameFramework","slug":"data-string-is-invalid","errorCode":null,"errorMessage":"Data string is invalid.","messagePattern":"Data string is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Base/DataProvider/DataProvider.cs","lineNumber":273,"sourceCode":"            return ParseData(dataString, null);\n        }\n\n        /// <summary>\n        /// 解析内容。\n        /// </summary>\n        /// <param name=\"dataString\">要解析的内容字符串。</param>\n        /// <param name=\"userData\">用户自定义数据。</param>\n        /// <returns>是否解析内容成功。</returns>\n        public bool ParseData(string dataString, object userData)\n        {\n            if (m_DataProviderHelper == null)\n            {\n                throw new GameFrameworkException(\"You must set data helper first.\");\n            }\n\n            if (dataString == null)\n            {\n                throw new GameFrameworkException(\"Data string is invalid.\");\n            }\n\n            try\n            {\n                return m_DataProviderHelper.ParseData(m_Owner, dataString, userData);\n            }\n            catch (Exception exception)\n            {\n                if (exception is GameFrameworkException)\n                {\n                    throw;\n                }\n\n                throw new GameFrameworkException(Utility.Text.Format(\"Can not parse data string with exception '{0}'.\", exception), exception);\n            }\n        }\n\n        /// <summary>","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Base/DataProvider/DataProvider.cs#L255-L291","documentation":"ParseData(string, object) validates that the dataString argument is non-null before delegating to the helper. A null string cannot be parsed, so the provider throws this explicit argument error. Empty strings are allowed; only null is rejected.","triggerScenarios":"Passing null (or an expression evaluating to null) as dataString to ParseData(string) or ParseData(string, object) — e.g. a failed file read or deserialization returned null upstream.","commonSituations":"Reading config text from a file/WebRequest that failed and returning null into ParseData; a property initialized to null used as the parse input; test harness passing null to check error handling.","solutions":["Ensure the string is loaded and non-null before calling ParseData.","Trace why the upstream source (file, network, resource load) produced null and fix that load.","If null is legitimately possible, check for null and handle it before parsing."],"exampleFix":"// before\nstring text = LoadText(); // may be null\nbool ok = dataProvider.ParseData(text, null);\n// after\nstring text = LoadText();\nif (text != null) { bool ok = dataProvider.ParseData(text, null); }","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(dataString)) { /* handle missing data */ }\nbool ok = dataProvider.ParseData(dataString, userData);","typeGuard":"bool IsParseable(string s) => s != null;","tryCatchPattern":"try { dataProvider.ParseData(text, null); }\ncatch (GameFrameworkException e) when (e.Message == \"Data string is invalid.\") { Log.Error(\"Parse input was null; check upstream load.\"); }","preventionTips":["Check load results before passing text into ParseData.","Avoid returning null from data-loading helper methods; return empty or throw early."],"tags":["null-argument","validation","parse"],"backgroundTag":"null-argument","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}