{"record":{"id":"e0122a2313e5acba","repo":"PrefectHQ/fastmcp","slug":"file-name-r-not-found-available-available","errorCode":null,"errorMessage":"File {name!r} not found. Available: {available}","messagePattern":"File (.+?) not found\\. Available: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/apps/file_upload.py","lineNumber":255,"sourceCode":"            ctx: The current request context.\n\n        Override this method for custom persistence. The default\n        implementation reads from the current scope's in-memory store.\n        Text files are decoded from base64; binary files return a\n        truncated base64 preview.\n\n        Returns:\n            Dict with file metadata and ``content`` (text) or\n            ``content_base64`` (binary preview).\n\n        Raises:\n            ValueError: If the file is not found.\n        \"\"\"\n        scope = self._get_scope_key(ctx)\n        session_files = self._store.get(scope, {})\n        if name not in session_files:\n            available = list(session_files.keys())\n            raise ValueError(f\"File {name!r} not found. Available: {available}\")\n        entry = session_files[name]\n        result: dict[str, Any] = {\n            \"name\": entry[\"name\"],\n            \"size\": entry[\"size\"],\n            \"type\": entry[\"type\"],\n            \"uploaded_at\": entry[\"uploaded_at\"],\n        }\n        is_text = entry[\"type\"].startswith(\"text/\") or any(\n            entry[\"name\"].endswith(ext) for ext in _TEXT_EXTENSIONS\n        )\n        if is_text:\n            try:\n                result[\"content\"] = base64.b64decode(entry[\"data\"]).decode(\"utf-8\")\n            except UnicodeDecodeError:\n                result[\"content_base64\"] = entry[\"data\"][:200] + \"...\"\n        else:\n            result[\"content_base64\"] = entry[\"data\"][:200] + \"...\"\n        return result","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/apps/file_upload.py#L237-L273","documentation":"FileUpload keeps uploaded files per session scope; reading a file whose name is not in the current session's store raises this ValueError listing the names that are available. It is a user-facing lookup failure, not a library bug.","triggerScenarios":"Calling the read/download tool with a `name` that was never uploaded in this session, or uploaded in a different session scope (different session key), or after the in-memory store was reset (server restart).","commonSituations":"Referring to a file by a different name than uploaded (client renames); cross-session access; server restarted losing the in-memory store; multiple users sharing a client with distinct session scopes.","solutions":["Use one of the names listed in the error's `Available: [...]` list.","Upload the file first in the same session, then read it by the exact uploaded name.","If the store was reset by a restart, re-upload the file."],"exampleFix":"// before\nread_file(name=\"report.pdf\")  # uploaded as \"Report.PDF\"\n// after\nread_file(name=\"Report.PDF\")  # exact name from upload response","handlingStrategy":"try-catch","validationCode":"available = list_uploadable_files(ctx)  # or track names returned by upload\nif name not in available:\n    raise KeyError(f\"{name!r} not uploaded in this session; available: {available}\")","typeGuard":null,"tryCatchPattern":"try:\n    result = read_file(name=filename)\nexcept ValueError as e:\n    if \"not found\" in str(e):\n        available = eval(str(e).split(\"Available:\")[1].strip())\n        filename = available[0]  # or prompt the user to pick","preventionTips":["Use the exact name returned by the upload response","Do not assume files persist across server restarts or session scopes","List available files before reading when unsure","Keep uploads and reads within the same session"],"tags":["python","valueerror","file-not-found","session-scope"],"backgroundTag":"resource-not-found","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}