{"record":{"id":"ba20c388f4c9a782","repo":"stride3d/stride","slug":"internal-error-unknown-directive-tok","errorCode":null,"errorMessage":"Internal error: Unknown directive {tok}","messagePattern":"Internal error: Unknown directive (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/CppNet/Preprocessor.cs","lineNumber":2140,"sourceCode":"                            if(!isActive())\n                                return source_skipline(false);\n                            return pragma();\n                        // break;\n\n                        case PP_IMPORT:\n                            if(!isActive())\n                                return source_skipline(false);\n                            else\n                                return import();\n\n                        default:\n                            /* Actual unknown directives are\n                             * processed above. If we get here,\n                             * we succeeded the map lookup but\n                             * failed to handle it. Therefore,\n                             * this is (unconditionally?) fatal. */\n                            // if (isActive()) /* XXX Could be warning. */\n                            throw new Exception(\n                                    \"Internal error: Unknown directive \"\n                                    + tok);\n                        // return source_skipline(false);\n                    }\n                BREAK_PP: ;\n                    break;\n\n\n\t\t\t}\n    BREAK_LEX: ;\n\t\t}\n\t}\n\n    private Token import()\n    {\n        return include(false, true);\n    }\n","sourceCodeStart":2122,"sourceCodeEnd":2158,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/CppNet/Preprocessor.cs#L2122-L2158","documentation":"Inside directive processing, the preprocessor looked up a directive name but found no handler case for it. Since genuine unknown directives are rejected earlier, reaching this throw means an internal dispatch inconsistency and it is thrown unconditionally as a fatal Exception.","triggerScenarios":"A recognized #directive is mapped but its handling case is missing — e.g. a directive added to the directive map without adding the corresponding case in the switch, hit while processing # lines in shader source.","commonSituations":"Custom forks of CppNet adding new directives incompletely; version mismatch between directive registration and dispatch switch after upstream changes.","solutions":["Add the missing switch case for the directive in the Preprocessor source","Remove the directive from the directive map if it should be treated as unknown","Update CppNet to a version where directive dispatch is consistent"],"exampleFix":"// before\n// no case for mydir\n// after\ncase \"mydir\":\n    handleMyDir();\n    break;","handlingStrategy":"try-catch","validationCode":"if (!directiveHandlers.ContainsKey(directiveName)) return SkipLine();","typeGuard":null,"tryCatchPattern":"try { ProcessDirectives(); } catch (Exception e) when (e.Message.StartsWith(\"Internal error\")) { log.Error($\"Directive dispatch bug: {e.Message}\"); }","preventionTips":["When adding a directive, register both the name map entry and the switch case","Run preprocessor tests over all supported directives after modifying dispatch code"],"tags":["shader","preprocessor","internal"],"backgroundTag":"internal-invariant-violation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}