Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch error in datastore #8149

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

avdata99
Copy link
Member

@avdata99 avdata99 commented Apr 3, 2024

Catch an error in datastore to avoid 500 error in POSTs to datatables/ajax/<resource_view_id>
The datastore_search action raises this error, it's captured later in this function but not here

Features:

  • includes tests covering changes
  • includes updated documentation
  • includes user-visible changes
  • includes API changes
  • includes bugfix for possible backport

Please [X] all the boxes above that apply

}
)
except ObjectNotFound:
return json.dumps({'error': 'Object not found'})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the response datatables expects on errors? Does it render the text in a dialog box or something?

Should probably also set the response status to 404.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also catch NotAuthorized here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wardi This function is a response for a POST and only returns JSON with no status (even for errors).
https://github.com/ckan/ckan/blob/master/ckanext/datatablesview/blueprint.py#L141
I just add statu codes for all responses

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also catch NotAuthorized here

Added here avdata99@ff1b9d7

@wardi wardi self-assigned this Apr 4, 2024
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.

None yet

2 participants