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 |
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 |
required |
Returns:
| Type | Description |
|---|---|
JobQueueManager
|
The single |
get_processor(request)
¶
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 |
None
|
Returns:
| Type | Description |
|---|---|
str | None
|
The Header value, or |
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 |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If the profile can't be read or created |