Skip to content

Validate event document URLs as URIs#192

Open
c-tonneslan wants to merge 1 commit into
openstates:mainfrom
c-tonneslan:fix/event-document-url-format
Open

Validate event document URLs as URIs#192
c-tonneslan wants to merge 1 commit into
openstates:mainfrom
c-tonneslan:fix/event-document-url-format

Conversation

@c-tonneslan

Copy link
Copy Markdown

The event documents schema (schemas/event.py) put url at the top level of each document as a plain non-empty string. That didn't match what Event.add_document actually writes (which is note + classification + a links array of {url, media_type}, via _add_associated_link), so the real url never hit the format: uri check and a relative path like /whatever/124.html silently passed validation.

Restructure the documents item schema to mirror what's already in the bill versions_or_documents and the event media_schema: a classification field plus a nested links array with uri-validated URLs. Added a regression test that asserts e.add_document(url='/relative.html') now fails validate().

Closes openstates/issues#1298.

The event documents schema treated url as a plain non-empty string
and put it at the top level of each document, which didn't match
what add_document actually writes (note + classification + a links
array of {url, media_type}). The result was that a relative path
like '/whatever/124.html' would pass validation silently, and the
real URL never got the format: uri check at all.

Restructure the documents item schema to mirror bill versions and
the existing event media schema: classification + nested links
with uri-validated urls. Added a regression test that asserts
e.add_document(url='/relative.html') now fails validation.

Closes openstates/issues#1298.

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Core should treat event document urls as URLs instead of strings

1 participant