Skip to navigation

nemo_gym.server_runtime.request_handling.errors

View as Markdown

Request validation errors: bounded, escaped logs of what was wrong, and the 422 response FastAPI returns.

Module Contents

Functions

NameDescription
_bounded_validation_error_value-
_escaped_log_prefixReturn a quoted, control-safe prefix bounded by max_chars.
_escaped_log_textReturn bounded, control-safe text with a visible marker when truncated.
_log_validation_exception-
_validation_error_summaries-
_validation_errors_log_textRender the error summaries for the log message, bounded by _VALIDATION_ERROR_LOG_ERRORS_CHARS.
_validation_exception_handler-

Data

_VALIDATION_ERROR_LOG_BODY_CHARS

_VALIDATION_ERROR_LOG_ERRORS_CHARS

_VALIDATION_ERROR_LOG_FIELD_CHARS

_VALIDATION_ERROR_LOG_LOC_ITEMS

_VALIDATION_ERROR_LOG_MAX_ERRORS

logger

API

nemo_gym.server_runtime.request_handling.errors._bounded_validation_error_value(
value: typing.Any
) -> tuple[typing.Any, bool]
nemo_gym.server_runtime.request_handling.errors._escaped_log_prefix(
value: str,
max_chars: int
) -> tuple[str, bool]

Return a quoted, control-safe prefix bounded by max_chars.

nemo_gym.server_runtime.request_handling.errors._escaped_log_text(
value: str,
max_chars: int
) -> tuple[str, bool]

Return bounded, control-safe text with a visible marker when truncated.

nemo_gym.server_runtime.request_handling.errors._log_validation_exception(
request: fastapi.Request,
exc: fastapi.exceptions.RequestValidationError
) -> None
async
nemo_gym.server_runtime.request_handling.errors._validation_error_summaries(
errors: list[dict[str, typing.Any]]
) -> tuple[list[dict[str, typing.Any]], bool]
nemo_gym.server_runtime.request_handling.errors._validation_errors_log_text(
error_summaries: list[dict[str, typing.Any]]
) -> tuple[str, bool]

Render the error summaries for the log message, bounded by _VALIDATION_ERROR_LOG_ERRORS_CHARS.

nemo_gym.server_runtime.request_handling.errors._validation_exception_handler(
request: fastapi.Request,
exc: fastapi.exceptions.RequestValidationError
) -> fastapi.Response
async
nemo_gym.server_runtime.request_handling.errors._VALIDATION_ERROR_LOG_BODY_CHARS = 4096
nemo_gym.server_runtime.request_handling.errors._VALIDATION_ERROR_LOG_ERRORS_CHARS = 4096
nemo_gym.server_runtime.request_handling.errors._VALIDATION_ERROR_LOG_FIELD_CHARS = 256
nemo_gym.server_runtime.request_handling.errors._VALIDATION_ERROR_LOG_LOC_ITEMS = 8
nemo_gym.server_runtime.request_handling.errors._VALIDATION_ERROR_LOG_MAX_ERRORS = 20
nemo_gym.server_runtime.request_handling.errors.logger = logging.getLogger(__name__)