Skip to content

Dependencies

dependencies

FastAPI request-scoped dependencies that bridge transport concerns (headers) to the domain layer

ensure_profile_exists(profile_id) async

Dependency that requires X-Profile-ID and ensures the profile exists

Implicitly creates the profile when it doesn't exist yet

Parameters:

Name Type Description Default
profile_id str

Profile id from the header

required

Returns:

Type Description
str

The validated profile id

Raises:

Type Description
HTTPException

If the X-Profile-ID header is missing

DatabaseError

If the profile can't be read or created

get_job_manager(request)

Endpoint dependency returning the lifespan-scoped JobQueueManager

Parameters:

Name Type Description Default
request Request

The FastAPI.Request object

required

Returns:

Type Description
JobQueueManager

The single JobQueueManager built during application startup

get_processor(request)

Endpoint dependency returning the lifespan-scoped Processor

Parameters:

Name Type Description Default
request Request

The FastAPI.Request object

required

Returns:

Type Description
Processor

The single Processor instance built during application startup

get_profile_id_from_header(x_profile_id=None) async

Extracts the X-Profile-ID header, returning None when it's not present

ASCII Only
  • The profile id is a segment of every media file's URL path (/media/profiles/<profile_id>/...)

  • A Modal-hosted deploy rejects any request whose URL path contains non-ASCII bytes, so a non-ASCII profile id is rejected here before it can be persisted and used as a storage path

  • The frontend also gates the profile-name input, this is the server-side backstop

Parameters:

Name Type Description Default
x_profile_id str | None

The X-Profile-ID Header

None

Returns:

Type Description
str | None

The Header value, or None when absent

Raises:

Type Description
HTTPException

400 when the header is present but not ASCII

get_profile_id_optional(profile_id) async

Dependency that returns the profile id when present, ensuring it exists

Parameters:

Name Type Description Default
profile_id str

Profile id from the header

required

Returns:

Type Description
str | None

The validated profile id, or None when the header is absent

Raises:

Type Description
DatabaseError

If the profile can't be read or created