ruvnet/RuView · info · HTTPException

Endpoint not available in production

Error message

Endpoint not available in production

What it means

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.

Source

Thrown at archive/v1/src/api/dependencies.py:462

    """Get current user for WebSocket connections."""
    return await get_websocket_user(websocket_token)


# Authentication requirement dependencies
async def require_auth(
    current_user: Dict[str, Any] = Depends(get_current_active_user)
) -> Dict[str, Any]:
    """Require authentication for endpoint access."""
    return current_user


# Development dependencies
async def development_only():
    """Dependency that only allows access in development."""
    settings = get_settings()
    
    if not settings.is_development:
        raise HTTPException(
            status_code=status.HTTP_404_NOT_FOUND,
            detail="Endpoint not available in production"
        )
    
    return True

View on GitHub (pinned to 4685618388)

Solutions

  1. Do not call dev-only endpoints in non-development deployments — use the production-equivalent route
  2. Locally, set the environment to development (e.g. ENVIRONMENT=development in .env) and restart the server
  3. If the capability must exist everywhere, replace Depends(development_only) on the route with an authentication dependency

Example fix

# before (hidden outside dev)
@router.get('/debug/config', dependencies=[Depends(development_only)])

# after (available to authenticated users)
@router.get('/debug/config', dependencies=[Depends(require_auth)])
Defensive patterns

Strategy: validation

Validate before calling

import os

IS_DEV = os.environ.get('ENVIRONMENT', 'development') == 'development'

async def call_dev_endpoint():
    if not IS_DEV:
        raise RuntimeError('endpoint only exists in development')
    return await client.get('/debug/config')

Try / catch

resp = await client.get('/dev-only-route')
if resp.status_code == 404 and 'not available in production' in resp.json().get('detail', ''):
    logger.warning('skipping dev-only endpoint outside development')

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16). Data as JSON: /api/errors/c95331a347df306b. Report an issue: GitHub.