{"record":{"id":"fd752a29bcfc63a4","repo":"pydantic/monty","slug":"non-filesystem-os-function-reached-filesystem-parser","errorCode":null,"errorMessage":"non-filesystem OS function reached filesystem parser","messagePattern":"non-filesystem OS function reached filesystem parser","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/monty-fs/src/dispatch.rs","lineNumber":171,"sourceCode":"            path: a.path,\n            parents: a.parents,\n            exist_ok: a.exist_ok,\n        },\n        OsFunctionCall::Unlink(path) => FsRequest::Unlink { path },\n        OsFunctionCall::Rmdir(path) => FsRequest::Rmdir { path },\n        OsFunctionCall::Iterdir(path) => FsRequest::Iterdir { path },\n        OsFunctionCall::Stat(path) => FsRequest::Stat { path },\n        OsFunctionCall::Rename(a) => FsRequest::Rename { src: a.src, dst: a.dst },\n        OsFunctionCall::Resolve(path) => FsRequest::Resolve { path },\n        OsFunctionCall::Absolute(path) => FsRequest::Absolute { path },\n        OsFunctionCall::Open(a) => FsRequest::Open {\n            path: a.path,\n            mode: a.mode,\n        },\n        OsFunctionCall::Getenv(_)\n        | OsFunctionCall::GetEnviron\n        | OsFunctionCall::DateToday\n        | OsFunctionCall::DateTimeNow(_) => unreachable!(\"non-filesystem OS function reached filesystem parser\"),\n    }\n}\n\n/// Routes a parsed request to the correct backend for the mount mode.\npub(super) fn execute(\n    request: FsRequest,\n    ctx: &mut MountContext<'_>,\n    mode: &mut MountMode,\n) -> Result<MontyObject, MountError> {\n    if request.is_write() && matches!(mode, MountMode::ReadOnly) {\n        Err(MountError::ReadOnly(request.primary_path().to_owned()))\n    } else {\n        match mode {\n            MountMode::ReadWrite | MountMode::ReadOnly => direct::execute(request, ctx),\n            MountMode::OverlayMemory(state) => overlay::execute(request, ctx, state),\n        }\n    }\n}","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/pydantic/monty/blob/adc986b362e3961f407868cb118a99fe831b9e61/crates/monty-fs/src/dispatch.rs#L153-L189","documentation":"An `unreachable!()` panic in monty-fs's OS-call dispatcher: `fs_request_from_call` is only supposed to receive filesystem-related `OsFunctionCall`s, but a non-filesystem variant (Getenv, GetEnviron, DateToday, DateTimeNow) reached it. This means dispatch upstream routed an OS call to the filesystem parser incorrectly.","triggerScenarios":"Servicing an `OsFunctionCall` via `MountTable::handle_os_call` when the top-level dispatcher fails to filter out `Getenv`/`GetEnviron`/`DateToday`/`DateTimeNow` and passes them into `fs_request_from_call`.","commonSituations":"Hit when a new OsFunctionCall variant is added and not added to the dispatcher's non-filesystem filter, or when a host binding routes os callbacks to the wrong handler.","solutions":["Fix the upstream dispatcher so non-filesystem OsFunctionCall variants are handled before reaching fs_request_from_call.","Add the new variant to the unreachable list (or better, to its proper handler) when extending OsFunctionCall.","Check that all host callers (pool, CLI, bindings) route os calls through the central dispatch function."],"exampleFix":"// before\nOsFunctionCall::Getenv(_) => unreachable!(...);\n// after (in the dispatcher, before fs parsing)\nOsFunctionCall::Getenv(a) => return handle_getenv(a),\nOsFunctionCall::DateToday => return handle_date_today(),","handlingStrategy":"validation","validationCode":"// Central dispatcher: route by category before fs parsing\nmatch call {\n    OsFunctionCall::Getenv(_) | OsFunctionCall::GetEnviron\n    | OsFunctionCall::DateToday | OsFunctionCall::DateTimeNow(_) => handle_non_fs(call),\n    _ => handle_fs(call),\n}","typeGuard":"fn is_fs_call(call: &OsFunctionCall) -> bool {\n    !matches!(call, OsFunctionCall::Getenv(_) | OsFunctionCall::GetEnviron\n        | OsFunctionCall::DateToday | OsFunctionCall::DateTimeNow(_))\n}","tryCatchPattern":null,"preventionTips":["When adding an OsFunctionCall variant, update every dispatcher match arm, including fs_request_from_call's unreachable list.","Route all host os-call servicing through one central dispatch function.","Add dispatch tests for each OsFunctionCall variant."],"tags":["rust","internal-error","panic","filesystem","os-calls"],"backgroundTag":"internal-invariant-violation","analyzedSha":"adc986b362e3961f407868cb118a99fe831b9e61","analyzedAt":"2026-09-13T19:19:18.698Z","contentChangedAt":"2026-09-13T19:19:18.698Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}