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

NoMethodError in datablock_storage#set_key_value undefined method `length' for nil:NilClass #57678

Closed
snickell opened this issue Apr 1, 2024 · 2 comments · Fixed by #58605
Closed

Comments

@snickell
Copy link
Contributor

snickell commented Apr 1, 2024

https://app.honeybadger.io/projects/3240/faults/106040647/01HTAX4Z0CE2K3SAQDGZX1H837?q=request.url%3A%22%2Adatablock%2A%22

@snickell
Copy link
Contributor Author

snickell commented Apr 1, 2024

The issue is that in some cases (how?) students are calling set_key_value with no value param set:

  def set_key_value
    raise StudentFacingError, "The value is too large. The maximum allowable size is #{DatablockStorageKvp::MAX_VALUE_LENGTH} bytes" if params[:value].length > DatablockStorageKvp::MAX_VALUE_LENGTH
    value = JSON.parse params[:value]
    DatablockStorageKvp.set_kvp @project_id, params[:key], value

This causes the exception in the raise StudentFacingError line, which checks params[:value].length.

We tried calling set_key_value("key", undefined) (which is a legal value to pass), but this did not trigger the error.

@snickell
Copy link
Contributor Author

snickell commented May 9, 2024

Quick fix, at the start of set_key_value do:
raise StudentFacingError, "key value must be specified" if not params[:value]

snickell added a commit that referenced this issue May 16, 2024
* Require params[:value] to be set, fixes #57678
* Update datablock_storage_controller.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant