4,150 matches across 25 files for error
snippet_mode: auto · sorted by relevance
39 field_annotation_is_sequence,
40 get_cached_model_fields,
41▶ get_missing_field_error,
42 is_bytes_or_nonable_bytes_annotation,
43 is_bytes_sequence_annotation,
· · ·
56)
57from fastapi.dependencies.models import Dependant
58▶from fastapi.exceptions import DependencyScopeError
59from fastapi.logger import logger
60from fastapi.security.oauth2 import SecurityScopes
· · ·
77from typing_inspection.typing_objects import is_typealiastype
78
79▶multipart_not_installed_error = (
80 'Form data requires "python-multipart" to be installed. \n'
81 'You can install "python-multipart" with: \n\n'
· · ·
82 "pip install python-multipart\n"
83)
84▶multipart_incorrect_install_error = (
85 'Form data requires "python-multipart" to be installed. '
86 'It seems you installed "multipart" instead. \n'
· · ·
98 # Import an attribute that can be mocked/deleted in testing
99 assert __version__ > "0.0.12"
100▶ except (ImportError, AssertionError):
101 try:
102 # __version__ is available in both multiparts, and can be mocked
+ 38 more matches in this file
54from fastapi.exceptions import (
55 EndpointContext,
56▶ FastAPIError,
57 RequestValidationError,
58 ResponseValidationError,
· · ·
57▶ RequestValidationError,
58 ResponseValidationError,
59 WebSocketRequestValidationError,
· · ·
58▶ ResponseValidationError,
59 WebSocketRequestValidationError,
60)
· · ·
59▶ WebSocketRequestValidationError,
60)
61from fastapi.sse import (
· · ·
123 response_awaited = True
124 if not response_awaited:
125▶ raise FastAPIError(
126 "Response not awaited. There's a high chance that the "
127 "application code is raising an exception and a dependency with yield "
+ 48 more matches in this file
217 lang_stage_path = zensical_src_path / lang
218 staged_docs_path = lang_stage_path / "content"
219▶ shutil.rmtree(lang_stage_path, ignore_errors=True)
220 shutil.copytree(en_docs_source_path, staged_docs_path)
221
· · ·
293 config = yaml.unsafe_load(config_path.read_text(encoding="utf-8"))
294 build_site_dist_path = config_path.parent / config["site_dir"]
295▶ shutil.rmtree(build_site_dist_path, ignore_errors=True)
296 build_zensical_config(config_path)
297 return build_site_dist_path
· · ·
304 else:
305 dist_path = site_path / lang
306▶ shutil.rmtree(dist_path, ignore_errors=True)
307 shutil.copytree(build_site_dist_path, dist_path, dirs_exist_ok=True)
308
· · ·
349 sponsors = yaml.safe_load(sponsors_data_path.read_text(encoding="utf-8"))
350 if not (match_start and match_end):
351▶ raise RuntimeError("Couldn't auto-generate sponsors section")
352 if not match_pre:
353 raise RuntimeError("Couldn't find pre section (<style>) in index.md")
· · ·
353▶ raise RuntimeError("Couldn't find pre section (<style>) in index.md")
354 frontmatter_end = match_pre.end()
355 pre_end = match_start.end()
+ 11 more matches in this file
40from starlette.routing import BaseRoute
41
42▶validation_error_definition = {
43 "title": "ValidationError",
44 "type": "object",
· · ·
43▶ "title": "ValidationError",
44 "type": "object",
45 "properties": {
· · ·
50 },
51 "msg": {"title": "Message", "type": "string"},
52▶ "type": {"title": "Error Type", "type": "string"},
53 "input": {"title": "Input"},
54 "ctx": {"title": "Context", "type": "object"},
· · ·
57}
58
59▶validation_error_response_definition = {
60 "title": "HTTPValidationError",
61 "type": "object",
· · ·
60▶ "title": "HTTPValidationError",
61 "type": "object",
62 "properties": {
+ 8 more matches in this file
11 websocket_request_validation_exception_handler,
12)
13▶from fastapi.exceptions import RequestValidationError, WebSocketRequestValidationError
14from fastapi.logger import logger
15from fastapi.middleware.asyncexitstack import AsyncExitStackMiddleware
· · ·
28from starlette.middleware import Middleware
29from starlette.middleware.base import BaseHTTPMiddleware
30▶from starlette.middleware.errors import ServerErrorMiddleware
31from starlette.middleware.exceptions import ExceptionMiddleware
32from starlette.requests import Request
· · ·
63 """
64 Boolean indicating if debug tracebacks should be returned on server
65▶ errors.
66
67 Read more in the
· · ·
495
496 Read more in the
497▶ [FastAPI docs for Handling Errors](https://fastapi.tiangolo.com/tutorial/handling-errors/).
498 """
499 ),
· · ·
1001 self.exception_handlers.setdefault(HTTPException, http_exception_handler)
1002 self.exception_handlers.setdefault(
1003▶ RequestValidationError, request_validation_exception_handler
1004 )
1005
+ 21 more matches in this file
20from fastapi.types import IncEx, ModelNameMap, UnionType
21from pydantic import BaseModel, ConfigDict, Field, TypeAdapter, create_model
22▶from pydantic import PydanticSchemaGenerationError as PydanticSchemaGenerationError
23from pydantic import PydanticUndefinedAnnotation as PydanticUndefinedAnnotation
24from pydantic import ValidationError as ValidationError
· · ·
24▶from pydantic import ValidationError as ValidationError
25from pydantic._internal import _typing_extra as _pydantic_typing_extra
26from pydantic._internal._schema_generation_shared import ( # type: ignore[attr-defined]
· · ·
183 [],
184 )
185▶ except ValidationError as exc:
186 return None, _regenerate_error_with_loc(
187 errors=exc.errors(include_url=False), loc_prefix=loc
· · ·
186▶ return None, _regenerate_error_with_loc(
187 errors=exc.errors(include_url=False), loc_prefix=loc
188 )
· · ·
187▶ errors=exc.errors(include_url=False), loc_prefix=loc
188 )
189
+ 10 more matches in this file
372 ),
373 ] = None,
374▶ auto_error: Annotated[
375 bool,
376 Doc(
· · ·
378 By default, if no HTTP Authorization header is provided, required for
379 OAuth2 authentication, it will automatically cancel the request and
380▶ send the client an error.
381
382 If `auto_error` is set to `False`, when the HTTP Authorization header
· · ·
382▶ If `auto_error` is set to `False`, when the HTTP Authorization header
383 is not available, instead of erroring out, the dependency result will
384 be `None`.
· · ·
383▶ is not available, instead of erroring out, the dependency result will
384 be `None`.
385
· · ·
397 )
398 self.scheme_name = scheme_name or self.__class__.__name__
399▶ self.auto_error = auto_error
400
401 def make_not_authenticated_error(self) -> HTTPException:
+ 17 more matches in this file
76 scheme_name: str | None = None,
77 description: str | None = None,
78▶ auto_error: bool = True,
79 ):
80 self.model = HTTPBaseModel(scheme=scheme, description=description)
· · ·
81 self.scheme_name = scheme_name or self.__class__.__name__
82▶ self.auto_error = auto_error
83
84 def make_authenticate_headers(self) -> dict[str, str]:
· · ·
85 return {"WWW-Authenticate": f"{self.model.scheme.title()}"}
86
87▶ def make_not_authenticated_error(self) -> HTTPException:
88 return HTTPException(
89 status_code=HTTP_401_UNAUTHORIZED,
· · ·
96 scheme, credentials = get_authorization_scheme_param(authorization)
97 if not (authorization and scheme and credentials):
98▶ if self.auto_error:
99 raise self.make_not_authenticated_error()
100 else:
· · ·
99▶ raise self.make_not_authenticated_error()
100 else:
101 return None
+ 28 more matches in this file
223 )
224 if response.status_code != 200:
225▶ logging.error(
226 f"Response was not 200, after: {after}, category_id: {category_id}"
227 )
· · ·
228▶ logging.error(response.text)
229 raise RuntimeError(response.text)
230 data = response.json()
· · ·
229▶ raise RuntimeError(response.text)
230 data = response.json()
231 if "errors" in data:
· · ·
231▶ if "errors" in data:
232 logging.error(f"Errors in response, after: {after}, category_id: {category_id}")
233 logging.error(data["errors"])
· · ·
232▶ logging.error(f"Errors in response, after: {after}, category_id: {category_id}")
233 logging.error(data["errors"])
234 logging.error(response.text)
+ 7 more matches in this file
50 try:
51 return isinstance(cls, type) and issubclass(cls, class_or_tuple) # type: ignore[arg-type] # ty: ignore[invalid-argument-type]
52▶ except TypeError: # pragma: no cover
53 if isinstance(cls, WithArgsTypes):
54 return False
· · ·
183 warnings.simplefilter("ignore", UserWarning)
184 from pydantic import v1
185▶ except ImportError: # pragma: no cover
186 return False
187 return isinstance(obj, v1.BaseModel)
· · ·
195 warnings.simplefilter("ignore", UserWarning)
196 from pydantic import v1
197▶ except ImportError: # pragma: no cover
198 return False
199 return lenient_issubclass(cls, v1.BaseModel)
14 commit_sha: str
15 run_id: int
16▶ state: Literal["pending", "success", "error"] = "pending"
17
18
· · ·
34 )
35 if not use_pr:
36▶ logging.error(f"No PR found for hash: {settings.commit_sha}")
37 return
38 commits = list(use_pr.get_commits())
· · ·
48 logging.info("No deploy URL available yet")
49 return
50▶ if settings.state == "error":
51 current_commit.create_status(
52 state="error",
· · ·
52▶ state="error",
53 description="Error Deploying Docs",
54 context="deploy-docs",
· · ·
53▶ description="Error Deploying Docs",
54 context="deploy-docs",
55 target_url=run_url,
+ 1 more matches in this file
207 )
208 if response.status_code != 200:
209▶ logging.error(
210 f"Response was not 200, after: {after}, category_id: {category_id}"
211 )
· · ·
212▶ logging.error(response.text)
213 raise RuntimeError(response.text)
214 data = response.json()
· · ·
213▶ raise RuntimeError(response.text)
214 data = response.json()
215 if "errors" in data:
· · ·
215▶ if "errors" in data:
216 logging.error(f"Errors in response, after: {after}, category_id: {category_id}")
217 logging.error(data["errors"])
· · ·
216▶ logging.error(f"Errors in response, after: {after}, category_id: {category_id}")
217 logging.error(data["errors"])
218 logging.error(response.text)
+ 3 more matches in this file
134 )
135 if response.status_code != 200:
136▶ logging.error(f"Response was not 200, after: {after}")
137 logging.error(response.text)
138 raise RuntimeError(response.text)
· · ·
137▶ logging.error(response.text)
138 raise RuntimeError(response.text)
139 data = response.json()
· · ·
138▶ raise RuntimeError(response.text)
139 data = response.json()
140 if "errors" in data:
· · ·
140▶ if "errors" in data:
141 logging.error(f"Errors in response, after: {after}")
142 logging.error(data["errors"])
· · ·
141▶ logging.error(f"Errors in response, after: {after}")
142 logging.error(data["errors"])
143 logging.error(response.text)
+ 3 more matches in this file
321 var isValid, qp, arr;
322
323▶ if (/code|token|error/.test(window.location.hash)) {
324 qp = window.location.hash.substring(1).replace('?', '&');
325 } else {
· · ·
356 oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
357 } else {
358▶ let oauthErrorMsg;
359 if (qp.error) {
360 oauthErrorMsg = "["+qp.error+"]: " +
· · ·
359▶ if (qp.error) {
360 oauthErrorMsg = "["+qp.error+"]: " +
361 (qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
· · ·
360▶ oauthErrorMsg = "["+qp.error+"]: " +
361 (qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
362 (qp.error_uri ? "More info: "+qp.error_uri : "");
· · ·
361▶ (qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
362 (qp.error_uri ? "More info: "+qp.error_uri : "");
363 }
+ 3 more matches in this file
10from fastapi._compat import (
11 ModelField,
12▶ PydanticSchemaGenerationError,
13 Undefined,
14 annotation_is_pydantic_v1,
· · ·
15)
16from fastapi.datastructures import DefaultPlaceholder, DefaultType
17▶from fastapi.exceptions import FastAPIDeprecationWarning, PydanticV1NotSupportedError
18from pydantic.fields import FieldInfo
19
· · ·
65) -> ModelField:
66 if annotation_is_pydantic_v1(type_):
67▶ raise PydanticV1NotSupportedError(
68 "pydantic.v1 models are no longer supported by FastAPI."
69 f" Please update the response model {type_!r}."
· · ·
72 try:
73 return v2.ModelField(mode=mode, name=name, field_info=field_info)
74▶ except PydanticSchemaGenerationError:
75 raise fastapi.exceptions.FastAPIError(
76 _invalid_args_message.format(type_=type_)
· · ·
75▶ raise fastapi.exceptions.FastAPIError(
76 _invalid_args_message.format(type_=type_)
77 ) from None
27 match = re.fullmatch(r"\d+\.\d+\.\d+", version)
28 if not match:
29▶ raise ValueError(f"Invalid version: {version!r}. Expected format: X.Y.Z")
30 major, minor, patch = version.split(".")
31 return int(major), int(minor), int(patch)
· · ·
35 matches = list(VERSION_PATTERN.finditer(content))
36 if len(matches) != 1:
37▶ raise RuntimeError(
38 f"Expected exactly one __version__ assignment in {version_file}, "
39 f"found {len(matches)}"
· · ·
54 current_version = get_current_version(content, version_file)
55 if parse_version(version) <= parse_version(current_version):
56▶ raise RuntimeError(
57 f"New version {version} must be greater than current version {current_version}"
58 )
· · ·
64) -> str:
65 if not content.startswith(RELEASE_NOTES_HEADER):
66▶ raise RuntimeError(
67 f"{release_notes_file} must start with {RELEASE_NOTES_HEADER!r}"
68 )
· · ·
69 if re.search(rf"^## {re.escape(version)}(?: \([^)]+\))?$", content, re.M):
70▶ raise RuntimeError(f"Release notes already contain a section for {version}")
71
72 latest_header = f"{RELEASE_NOTES_HEADER}{LATEST_CHANGES_HEADER}\n"
+ 3 more matches in this file
18 description: str | None,
19 scheme_name: str | None,
20▶ auto_error: bool,
21 ):
22 self.auto_error = auto_error
· · ·
22▶ self.auto_error = auto_error
23
24 self.model: APIKey = APIKey(
· · ·
29 self.scheme_name = scheme_name or self.__class__.__name__
30
31▶ def make_not_authenticated_error(self) -> HTTPException:
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
· · ·
47 def check_api_key(self, api_key: str | None) -> str | None:
48 if not api_key:
49▶ if self.auto_error:
50 raise self.make_not_authenticated_error()
51 return None
+ 16 more matches in this file
122
123 if len(code_include_lines) != len(original_includes):
124▶ raise ValueError(
125 "Number of code include placeholders does not match the number of code includes "
126 "in the original document "
· · ·
221
222 if len(header_permalinks) != len(original_header_permalinks):
223▶ raise ValueError(
224 "Number of headers with permalinks does not match the number in the "
225 "original document "
· · ·
232
233 if header_info["hashes"] != original_header_info["hashes"]:
234▶ raise ValueError(
235 "Header levels do not match between document and original document"
236 f" (found {header_info['hashes']}, expected {original_header_info['hashes']})"
· · ·
321
322 if len(links) != len(original_links):
323▶ raise ValueError(
324 "Number of markdown links does not match the number in the "
325 "original document "
· · ·
445
446 if len(links) != len(original_links):
447▶ raise ValueError(
448 "Number of HTML links does not match the number in the "
449 "original document "
+ 5 more matches in this file
20
21from annotated_doc import Doc
22▶from fastapi.exceptions import PydanticV1NotSupportedError
23from fastapi.types import IncEx
24from pydantic import BaseModel
· · ·
35 # pydantic.color.Color is deprecated since v2.0b3, but supporting for bwd-compat
36 from pydantic.color import Color # ty: ignore[deprecated]
37▶except ImportError: # pragma: no cover
38
39 class Color: # type: ignore[no-redef]
· · ·
44 # Supporting the new Color format for newer versions of Pydantic
45 from pydantic_extra_types.color import Color as PyExtraColor
46▶except ImportError: # pragma: no cover
47
48 class PyExtraColor: # type: ignore[no-redef]
· · ·
338 return encoder(obj)
339 if is_pydantic_v1_model_instance(obj):
340▶ raise PydanticV1NotSupportedError(
341 "pydantic.v1 models are no longer supported by FastAPI."
342 f" Please update the model {obj!r}."
· · ·
345 data = dict(obj)
346 except Exception as e:
347▶ errors: list[Exception] = []
348 errors.append(e)
349 try:
+ 3 more matches in this file
8 SecurityScopes,
9)
10▶from jwt.exceptions import InvalidTokenError
11from pwdlib import PasswordHash
12from pydantic import BaseModel, ValidationError
· · ·
12▶from pydantic import BaseModel, ValidationError
13
14# to get a string like this run:
· · ·
125 token_scopes = scope.split(" ")
126 token_data = TokenData(scopes=token_scopes, username=username)
127▶ except (InvalidTokenError, ValidationError):
128 raise credentials_exception
129 user = get_user(fake_users_db, username=token_data.username)
9 SecurityScopes,
10)
11▶from jwt.exceptions import InvalidTokenError
12from pwdlib import PasswordHash
13from pydantic import BaseModel, ValidationError
· · ·
13▶from pydantic import BaseModel, ValidationError
14
15# to get a string like this run:
· · ·
126 token_scopes = scope.split(" ")
127 token_data = TokenData(scopes=token_scopes, username=username)
128▶ except (InvalidTokenError, ValidationError):
129 raise credentials_exception
130 user = get_user(fake_users_db, username=token_data.username)
105 )
106 if response.status_code != 200:
107▶ logging.error(f"Response was not 200, after: {after}")
108 logging.error(response.text)
109 raise RuntimeError(response.text)
· · ·
108▶ logging.error(response.text)
109 raise RuntimeError(response.text)
110 data = response.json()
· · ·
109▶ raise RuntimeError(response.text)
110 data = response.json()
111 if "errors" in data:
· · ·
111▶ if "errors" in data:
112 logging.error(f"Errors in response, after: {after}")
113 logging.error(data["errors"])
· · ·
112▶ logging.error(f"Errors in response, after: {after}")
113 logging.error(data["errors"])
114 logging.error(response.text)
+ 3 more matches in this 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 ),
+ 26 more matches in this file
68 const promptStart = line.indexOf(promptLiteralStart);
69 if (promptStart === -1) {
70▶ console.error("Custom prompt found but no end delimiter", line)
71 }
72 const prompt = line.slice(0, promptStart).replace(customPromptLiteralStart, "")
· · ·
160 }
161 });
162▶ img.addEventListener('error', reject);
163 }
164 });
94 path.write_text("\n".join(doc_lines), encoding="utf-8")
95
96▶ except ValueError as e:
97 print(f"Error processing {path}: {e}")
98 return False
· · ·
97▶ print(f"Error processing {path}: {e}")
98 return False
99 return True