46 matches across 16 files for error
snippet_mode: auto · sorted by relevance
fastapi/security/http.py PYTHON 7 matches · showing 5 view file →
175 By default, if the HTTP Basic authentication is not provided (a
176 header), `HTTPBasic` will automatically cancel the request and send the
177 client an error.
178
179 If `auto_error` is set to `False`, when the HTTP Basic authentication
· · ·
179 If `auto_error` is set to `False`, when the HTTP Basic authentication
180 is not available, instead of erroring out, the dependency result will
181 be `None`.
· · ·
180 is not available, instead of erroring out, the dependency result will
181 be `None`.
182
· · ·
282 By default, if the HTTP Bearer token is not provided (in an
283 `Authorization` header), `HTTPBearer` will automatically cancel the
284 request and send the client an error.
285
286 If `auto_error` is set to `False`, when the HTTP Bearer token
· · ·
286 If `auto_error` is set to `False`, when the HTTP Bearer token
287 is not available, instead of erroring out, the dependency result will
288 be `None`.
+ 2 more matches in this file
fastapi/exceptions.py PYTHON 11 matches · showing 5 view file →
17class HTTPException(StarletteHTTPException):
18 """
19 An HTTP exception you can raise in your own code to show errors to the client.
20
21 This is for client errors, invalid authentication, invalid data, etc. Not for server
· · ·
21 This is for client errors, invalid authentication, invalid data, etc. Not for server
22 errors in your code.
23
· · ·
22 errors in your code.
23
24 Read more about it in the
· · ·
25 [FastAPI docs for Handling Errors](https://fastapi.tiangolo.com/tutorial/handling-errors/).
26
27 ## Example
· · ·
52
53 Read more about it in the
54 [FastAPI docs for Handling Errors](https://fastapi.tiangolo.com/tutorial/handling-errors/#use-httpexception)
55 """
56 ),
+ 6 more matches in this file
fastapi/security/api_key.py PYTHON 5 matches view file →
32 """
33 The WWW-Authenticate header is not standardized for API Key authentication but
34 the HTTP specification requires that an error of 401 "Unauthorized" must
35 include a WWW-Authenticate header.
36
· · ·
112 ),
113 ] = None,
114 auto_error: Annotated[
115 bool,
116 Doc(
· · ·
137 scheme_name=scheme_name,
138 description=description,
139 auto_error=auto_error,
140 )
141
· · ·
289 ),
290 ] = None,
291 auto_error: Annotated[
292 bool,
293 Doc(
· · ·
313 scheme_name=scheme_name,
314 description=description,
315 auto_error=auto_error,
316 )
317
fastapi/security/oauth2.py PYTHON 2 matches view file →
486 ),
487 ] = None,
488 auto_error: Annotated[
489 bool,
490 Doc(
· · ·
599 ),
600 ] = None,
601 auto_error: Annotated[
602 bool,
603 Doc(
fastapi/applications.py PYTHON 6 matches · showing 5 view file →
64 """
65 Boolean indicating if debug tracebacks should be returned on server
66 errors.
67
68 Read more in the
· · ·
1003 self.exception_handlers.setdefault(HTTPException, http_exception_handler)
1004 self.exception_handlers.setdefault(
1005 RequestValidationError, request_validation_exception_handler
1006 )
1007
· · ·
1008 # Starlette still has incorrect type specification for the handlers
1009 self.exception_handlers.setdefault(
1010 WebSocketRequestValidationError,
1011 websocket_request_validation_exception_handler, # type: ignore[arg-type]
1012 ) # ty: ignore[no-matching-overload]
· · ·
1022 # inside of ExceptionMiddleware, inside of custom user middlewares
1023 debug = self.debug
1024 error_handler = None
1025 exception_handlers: dict[Any, ExceptionHandler] = {}
1026
· · ·
1027 for key, value in self.exception_handlers.items():
1028 if key in (500, Exception):
1029 error_handler = value
1030 else:
1031 exception_handlers[key] = value
+ 1 more matches in this file
scripts/translate.py PYTHON 1 matches view file →
161 path=str(out_path),
162 )
163 break # Exit loop if no errors
164 except ValueError as e:
165 print(
tests/test_ws_router.py PYTHON 4 matches view file →
228 with client.websocket_connect("/depends-validate/"):
229 pass # pragma: no cover
230 # the validation error does produce a close message
231 assert e.value.code == status.WS_1008_POLICY_VIOLATION
232 # and no error is leaked
· · ·
232 # and no error is leaked
233 assert caught == []
234
· · ·
236def test_depend_err_middleware():
237 """
238 Verify that it is possible to write custom WebSocket middleware to catch errors
239 """
240
· · ·
257def test_depend_err_handler():
258 """
259 Verify that it is possible to write custom WebSocket middleware to catch errors
260 """
261
scripts/doc_parsing_utils.py PYTHON 1 matches view file →
650 `original_code_blocks` with comments taken from `code_blocks`.
651
652 Raises ValueError if the number, language, or shape of code blocks do not match.
653 """
654
tests/test_dependency_after_yield_streaming.py PYTHON 1 matches view file →
114
115def test_broken_session_stream_raise():
116 # Can raise ValueError on Pydantic v2 and ExceptionGroup on Pydantic v1
117 with pytest.raises((ValueError, Exception)):
118 client.get("/broken-session-stream")
fastapi/routing.py PYTHON 2 matches view file →
403 )
404
405 # Extract endpoint context for error messages
406 endpoint_ctx = (
407 _extract_endpoint_context(dependant.call)
· · ·
556 # from the generator independently, so
557 # `anyio.fail_after` never wraps the generator's
558 # `__anext__` directly - avoiding CancelledError that
559 # would finalize the generator and also working for sync
560 # generators running in a thread pool.
tests/test_inherited_custom_class.py PYTHON 1 matches view file →
20 @property
21 def __dict__(self):
22 """Spoof a missing __dict__ by raising TypeError, this is how
23 asyncpg.pgroto.pgproto.UUID behaves"""
24 raise TypeError("vars() argument must have __dict__ attribute")
pyproject.toml TOML 1 matches view file →
264[tool.ruff.lint]
265select = [
266 "E", # pycodestyle errors
267 "W", # pycodestyle warnings
268 "F", # pyflakes
tests/test_openapi_schema_type.py PYTHON 1 matches view file →
20
21def test_invalid_type_value() -> None:
22 """Test that Schema raises ValueError for invalid type values."""
23 with pytest.raises(ValueError, match="2 validation errors for Schema"):
24 Schema(type=True) # type: ignore[arg-type] # ty: ignore[invalid-argument-type]
tests/test_additional_responses_bad.py PYTHON 1 matches view file →
19 "responses": {
20 # this is how one would imagine the openapi schema to be
21 # but since the key is not valid, openapi.utils.get_openapi will raise ValueError
22 "hello": {"description": "Not a valid additional response"},
23 "200": {
tests/test_file_and_form_order_issue_9116.py PYTHON 1 matches view file →
1"""
2Regression test, Error 422 if Form is declared before File
3See https://github.com/tiangolo/fastapi/discussions/9116
4"""
.github/workflows/test.yml YAML 1 matches view file →
149 CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.deprecated-tests}}
150 PYTEST_OPTIONS: ${{ (matrix.without-httpx2 == 'true') && '-W ignore::UserWarning' || '' }}
151 # Do not store coverage for all possible combinations to avoid file size max errors in Smokeshow
152 - name: Store coverage files
153 if: matrix.coverage == 'coverage'
Search syntax
auth loginboth terms (AND is implicit)
auth OR logineither term
NOT path:vendorexclude matches
"exact phrase"quoted exact match
/func\s+Test/regex
handler~1fuzzy (Levenshtein 1)
file:*_test.gofilename glob
path:pkg/auth/**full path glob
lang:golanguage filter

Search any public repo from your terminal

This page calls POST /api/v1/code_search. Same tool, available over MCP for Claude/Cursor/Copilot.