MCPcopy Create free account
hub / github.com/LaunchPlatform/beanhub-cli / form_doc_errors

Function form_doc_errors

beanhub_cli/forms/app/routes.py:128–162  ·  view source on GitHub ↗
(
    request: Request,
    templates: deps.Jinja2TemplatesDep,
    raw_form_doc: deps.RawFormDocDep,
    url_for: deps.UrlForDep,
)

Source from the content-addressed store, hash-verified

126
127@router.get("/errors")
128def form_doc_errors(
129 request: Request,
130 templates: deps.Jinja2TemplatesDep,
131 raw_form_doc: deps.RawFormDocDep,
132 url_for: deps.UrlForDep,
133) -> Response:
134 if raw_form_doc is None:
135 return RedirectResponse(url_for("home"))
136 doc_path, raw_doc = raw_form_doc
137
138 valid_doc = False
139 yaml_error: typing.Optional[yaml.parser.ParserError] = None
140 validation_error: typing.Optional[ValidationError] = None
141 value_error: typing.Optional[ValueError] = None
142 try:
143 FormDoc.model_validate(yaml.safe_load(io.StringIO(raw_doc)))
144 valid_doc = True
145 except (yaml.parser.ParserError, yaml.scanner.ScannerError) as exc:
146 yaml_error = exc
147 except ValidationError as exc:
148 validation_error = exc
149 except ValueError as exc:
150 value_error = exc
151
152 return templates.TemplateResponse(
153 request,
154 "errors.html",
155 dict(
156 doc_path=doc_path,
157 validation_error=validation_error,
158 value_error=value_error,
159 yaml_error=yaml_error,
160 valid_doc=valid_doc,
161 ),
162 )
163
164
165@router.post("/create-sample-doc")

Callers

nothing calls this directly

Calls 1

url_forFunction · 0.85

Tested by

no test coverage detected