core_config
¶
Configuration management for Genres Autoupdater v2.0.
ConfigurationError
¶
Bases: Exception
Raised when configuration loading or parsing fails.
Initialize the configuration error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Error description |
required |
config_path
|
str | None
|
Path to the config file that caused the error |
None
|
Source code in src/core/core_config.py
resolve_env_vars
¶
Recursively resolve environment variables in config values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ConfigValue
|
Configuration value (dict, list, or primitive). |
required |
Returns:
| Type | Description |
|---|---|
ConfigValue
|
Config with environment variables resolved. |
Source code in src/core/core_config.py
validate_required_env_vars
¶
Validate required environment variables.
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: List of missing required environment variables. |
Source code in src/core/core_config.py
load_config
¶
Load the configuration from a YAML file, resolve environment variables, and validate it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
str
|
Path to the configuration YAML file. |
required |
Returns:
| Type | Description |
|---|---|
AppConfig
|
Validated AppConfig Pydantic model with resolved env vars. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the config file does not exist. |
ValueError
|
If the configuration is invalid, the path is insecure, or env vars are missing. |
PermissionError
|
If the config file cannot be read. |
YAMLError
|
If there is an error parsing the YAML file. |
RuntimeError
|
For unexpected errors during additional validation steps. |
Source code in src/core/core_config.py
format_pydantic_errors
¶
Format Pydantic validation errors into a readable string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error
|
ValidationError
|
Pydantic ValidationError instance. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted error message string. |
Source code in src/core/core_config.py
validate_api_auth
¶
Validate that API authentication fields are non-empty after env var resolution.
Pydantic ensures ApiAuthConfig fields exist, but they may resolve
to empty strings when the corresponding environment variables are unset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_auth
|
ApiAuthConfig
|
Typed API authentication configuration. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required credentials are empty. |