{"record":{"id":"c95331a347df306b","repo":"ruvnet/RuView","slug":"endpoint-not-available-in-production","errorCode":null,"errorMessage":"Endpoint not available in production","messagePattern":"Endpoint not available in production","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"info","filePath":"archive/v1/src/api/dependencies.py","lineNumber":462,"sourceCode":"    \"\"\"Get current user for WebSocket connections.\"\"\"\n    return await get_websocket_user(websocket_token)\n\n\n# Authentication requirement dependencies\nasync def require_auth(\n    current_user: Dict[str, Any] = Depends(get_current_active_user)\n) -> Dict[str, Any]:\n    \"\"\"Require authentication for endpoint access.\"\"\"\n    return current_user\n\n\n# Development dependencies\nasync def development_only():\n    \"\"\"Dependency that only allows access in development.\"\"\"\n    settings = get_settings()\n    \n    if not settings.is_development:\n        raise HTTPException(\n            status_code=status.HTTP_404_NOT_FOUND,\n            detail=\"Endpoint not available in production\"\n        )\n    \n    return True","sourceCodeStart":444,"sourceCodeEnd":467,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/api/dependencies.py#L444-L467","documentation":"Raised as HTTP 404 by the development_only dependency at dependencies.py:462 when an endpoint marked dev-only is called outside development mode (settings.is_development falsy). The 404 (instead of 403) is deliberate so production does not confirm the route exists. Behavior depends entirely on how the environment/ENVIRONMENT setting was loaded at startup.","triggerScenarios":"Calling any route wired with Depends(development_only) while the loaded settings have is_development == False, e.g. ENVIRONMENT=production in the environment or .env.","commonSituations":"A Postman collection or script built against a dev server is reused against staging/production; the .env file is missing in a container so settings fall back away from development; CI runs with production-like env vars.","solutions":["Do not call dev-only endpoints in non-development deployments — use the production-equivalent route","Locally, set the environment to development (e.g. ENVIRONMENT=development in .env) and restart the server","If the capability must exist everywhere, replace Depends(development_only) on the route with an authentication dependency"],"exampleFix":"# before (hidden outside dev)\n@router.get('/debug/config', dependencies=[Depends(development_only)])\n\n# after (available to authenticated users)\n@router.get('/debug/config', dependencies=[Depends(require_auth)])","handlingStrategy":"validation","validationCode":"import os\n\nIS_DEV = os.environ.get('ENVIRONMENT', 'development') == 'development'\n\nasync def call_dev_endpoint():\n    if not IS_DEV:\n        raise RuntimeError('endpoint only exists in development')\n    return await client.get('/debug/config')","typeGuard":null,"tryCatchPattern":"resp = await client.get('/dev-only-route')\nif resp.status_code == 404 and 'not available in production' in resp.json().get('detail', ''):\n    logger.warning('skipping dev-only endpoint outside development')","preventionTips":["Keep per-environment client configs; never reuse dev collections against prod","Confirm the loaded environment (via a /version or config endpoint) before calling dev routes","Treat 404-with-that-detail as a normal non-dev response, not a bug"],"tags":["python","fastapi","configuration","environment","http-404"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}