{"record":{"id":"3f3256661e2c6327","repo":"BabylonJS/Babylon.js","slug":"unknown-interceptor-type-type","errorCode":null,"errorMessage":"Unknown interceptor type: ${type}","messagePattern":"Unknown interceptor type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/inspector-v2/src/hooks/instrumentationHooks.ts","lineNumber":37,"sourceCode":"    const observable = useMemo(() => new Observable<void>(), []);\r\n\r\n    const watcher = useWatcher();\r\n\r\n    // Whenever the type, target, or property key changes, we need to set up a new interceptor.\r\n    useEffect(() => {\r\n        let interceptToken: Nullable<IDisposable> = null;\r\n\r\n        if (target) {\r\n            if (type === \"function\") {\r\n                interceptToken = InterceptFunction(target, propertyKey, {\r\n                    afterCall: () => {\r\n                        observable.notifyObservers();\r\n                    },\r\n                });\r\n            } else if (type === \"property\") {\r\n                interceptToken = watcher.watchProperty(target, propertyKey, () => observable.notifyObservers());\r\n            } else {\r\n                throw new Error(`Unknown interceptor type: ${type}`);\r\n            }\r\n        }\r\n\r\n        // When the effect is cleaned up, we need to dispose of the interceptor.\r\n        return () => {\r\n            interceptToken?.dispose();\r\n        };\r\n    }, [type, target, propertyKey, observable]);\r\n\r\n    return observable;\r\n}\r\n","sourceCodeStart":19,"sourceCodeEnd":49,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/inspector-v2/src/hooks/instrumentationHooks.ts#L19-L49","documentation":"useInterceptObservable's internal watcher supports a fixed set of interceptor types (e.g. \"property\" and observable watching). When the hook is given a type value that the switch statement does not recognize, it throws because no interceptor could be registered — the watched target would silently never notify. The message includes the offending type for diagnosis.","triggerScenarios":"Passing a type string to useInterceptObservable (or its wrapper hooks) that is not one of the supported literals — e.g. a typo like \"propert\" or \"observable\", a renamed type after a library update, or a dynamic type computed at runtime.","commonSituations":"Upgrading inspector-v2 where interceptor type literals changed; writing a generic wrapper that forwards a user-supplied type string without validation; copy-pasting a hook call from docs of a different version.","solutions":["Use one of the supported literal types exactly as defined in instrumentationHooks.ts (e.g. \"property\").","Type the parameter as a union of the supported literals so invalid values fail at compile time.","Log the computed type before calling the hook to find where the bad value originates.","Check the changelog of inspector-v2 for renamed interceptor types after upgrading."],"exampleFix":"// before\nuseInterceptObservable(target, key, { type: kind }); // kind: string = \"proprety\"\n\n// after\nconst validTypes = [\"property\", \"observable\"] as const;\ntype InterceptorType = (typeof validTypes)[number];\nconst kind: InterceptorType = \"property\";\nuseInterceptObservable(target, key, { type: kind });","handlingStrategy":"type-guard","validationCode":"const SUPPORTED_TYPES = [\"property\", \"observable\"] as const;\nif (!SUPPORTED_TYPES.includes(type as any)) {\n  throw new TypeError(`Unsupported interceptor type: ${type}`);\n}","typeGuard":"function isInterceptorType(v: string): v is \"property\" | \"observable\" {\n  return v === \"property\" || v === \"observable\";\n}","tryCatchPattern":"try {\n  useInterceptObservable(target, key, { type });\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith(\"Unknown interceptor type\")) {\n    console.error(\"Bad interceptor type:\", type);\n  } else {\n    throw e;\n  }\n}","preventionTips":["Type the type parameter as a string literal union, not string.","Keep wrapper hooks in sync with instrumentationHooks.ts supported types.","Grep the changelog when upgrading inspector-v2 versions.","Unit-test each wrapper hook with its declared type literal."],"tags":["react-hooks","instrumentation","invalid-argument"],"backgroundTag":"invalid-enum-value","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}