EllanJiang/GameFramework · critical · GameFrameworkException

You must set data helper first.

Error message

You must set data helper first.

What it means

ParseData(string, object) — the string-based parse entry — needs an IDataProviderHelper to perform the actual parsing. If SetDataProviderHelper was never called (m_DataProviderHelper == null) it throws immediately. Initialization-order guard, thrown before the dataString is even inspected.

Solutions

  1. Call SetDataProviderHelper(helper) before any ParseData call.
  2. Reuse the same helper assignment used for ReadData on this provider instance.
  3. In tests/tools, construct and register a concrete IDataProviderHelper implementation first.

Example fix

// before
bool ok = dataProvider.ParseData(json, null); // helper missing
// after
dataProvider.SetDataProviderHelper(helper);
bool ok = dataProvider.ParseData(json, null);
Defensive patterns

Strategy: validation

Validate before calling

if (m_DataProviderHelper == null) { /* call SetDataProviderHelper */ }
bool ok = dataProvider.ParseData(text, userData);

Type guard

bool HasHelper(IDataProviderHelper h) => h != null;

Try / catch

try { dataProvider.ParseData(text, null); }
catch (GameFrameworkException e) when (e.Message.Contains("data helper")) { Log.Error("Call SetDataProviderHelper before ParseData."); }

Prevention

When it happens

Trigger: Calling ParseData(dataString, userData) (or the ParseData(string) overload) on a DataProvider without a helper assigned via SetDataProviderHelper.

Common situations: Using the string-parse path in a provider configured only for asset loading; helper assignment skipped in custom initialization code; helper component missing in the Unity scene.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/77d921c22e27a0bd. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/Base/DataProvider/DataProvider.cs:268

        /// </summary>
        /// <param name="dataString">要解析的内容字符串。</param>
        /// <returns>是否解析内容成功。</returns>
        public bool ParseData(string dataString)
        {
            return ParseData(dataString, null);
        }

        /// <summary>
        /// 解析内容。
        /// </summary>
        /// <param name="dataString">要解析的内容字符串。</param>
        /// <param name="userData">用户自定义数据。</param>
        /// <returns>是否解析内容成功。</returns>
        public bool ParseData(string dataString, object userData)
        {
            if (m_DataProviderHelper == null)
            {
                throw new GameFrameworkException("You must set data helper first.");
            }

            if (dataString == null)
            {
                throw new GameFrameworkException("Data string is invalid.");
            }

            try
            {
                return m_DataProviderHelper.ParseData(m_Owner, dataString, userData);
            }
            catch (Exception exception)
            {
                if (exception is GameFrameworkException)
                {
                    throw;
                }

View on GitHub (pinned to d0c010b051)