feat(api): add /type/tag to /api/new allowed types - #13088
Merged
Merged
Conversation
Allows api-group bots to create new Tag documents via /api/new, which assigns a new OLID via new_key() and saves the document. Previously /type/tag was absent from the allowlist, forcing callers to hardcode OLIDs when using save_many.
for more information, see https://pre-commit.ci
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the legacy Infogami /api/new endpoint (implemented in the Open Library plugin) to allow creation of tag documents by adding /type/tag to the endpoint’s type allowlist, enabling API clients/bots to obtain new /tags/OL…T keys via new_key().
Changes:
- Add
/type/tagto the/api/newverify_typesallowlist so tag documents can be created through the API. - Minor import reordering within
openlibrary/plugins/openlibrary/code.py(no behavioral change observed from the import moves themselves).
Previously a missing 'key' field caused an opaque KeyError inside infogami's process_many, surfaced as a generic 400 internal_error with no actionable message. Now caught in OLConnection.save_many and returned as a descriptive bad_data response before hitting infogami.
for more information, see https://pre-commit.ci
Member
Author
|
https://openlibrary.org/permission/tag-editors.json |
Member
Author
|
This would be good to also have on local instances |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
/type/tagto the allowlist in the/api/newendpoint'sverify_typescheck.Previously, api-group bots could write to existing tag documents via
save_manybut had no way to create new ones —/api/newrejected/type/tagwithBadRequest, and there is no other external path to Infogami'snew_key()which assigns OLIDs.With this change, creating a tag via the API works as expected:
Related
/tagsnamespace document withchild_permission: /permission/tag-editorsto be in place (applied directly to production Infogami —/usergroup/apiadded to writers)Content-Type: application/jsonon session to pass ModSecurity WAF rule 920340Testing