-
Notifications
You must be signed in to change notification settings - Fork 482
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
Enforce MAX_TABLE_ROW_COUNT, MAX_TABLE_COUNT, MAX_RECORD_LENGTH, MAX_NUM_KVPS and MAX_VALUE_LENGTH #58598
Conversation
snickell
commented
May 14, 2024
•
edited
edited
- Enforces MAX_TABLE_ROW_COUNT, Fixes: #57002
- Enforces MAX_TABLE_COUNT, Fixes: #57003
- Enforces MAX_RECORD_LENGTH, Fixes: #57001
- Enforces MAX_NUM_KVPS, Fixes #57000
- Enforces MAX_VALUE_LENGTH, Fixes #56999
- Stops skipping tests for all of the above now that they're working
@@ -237,8 +235,6 @@ def read_records | |||
end | |||
|
|||
def update_record | |||
raise StudentFacingError, "The record is too large. The maximum allowable size is #{DatablockStorageRecord::MAX_RECORD_LENGTH} bytes" if params[:record_json].length > DatablockStorageRecord::MAX_RECORD_LENGTH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing these in favor of validations on the model
@@ -219,7 +218,6 @@ def get_columns_for_table | |||
########################################################## | |||
|
|||
def create_record | |||
raise StudentFacingError, "The record is too large. The maximum allowable size is #{DatablockStorageRecord::MAX_RECORD_LENGTH} bytes" if params[:record_json].length > DatablockStorageRecord::MAX_RECORD_LENGTH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing these in favor of validations on the model
@@ -61,7 +61,6 @@ def index | |||
########################################################## | |||
|
|||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing these in favor of validations on the model
@@ -621,26 +632,26 @@ def create_shared_table | |||
end | |||
|
|||
test "import_csv" do | |||
CSV_DATA = <<~CSV | |||
csv_data = <<~CSV |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the noise on these, I guess CAPS means its a class level constant, and ruby was generating warnings, this makes the warnings go away
@@ -17,17 +17,16 @@ class DatablockStorageKvp < ApplicationRecord | |||
|
|||
self.primary_keys = :project_id, :key | |||
|
|||
validate :max_kvp_count, on: :create | |||
validate :max_value_length, on: [:create, :update] | |||
|
|||
StudentFacingError = DatablockStorageTable::StudentFacingError | |||
|
|||
# TODO: #56999, implement enforcement of MAX_VALUE_LENGTH, we already have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comment!
|
||
private def max_record_length | ||
if record_json.to_json.bytesize > MAX_RECORD_LENGTH | ||
raise StudentFacingError.new(:MAX_RECORD_LENGTH_EXCEEDED), "JSON data cannot exceed #{MAX_RECORD_LENGTH} bytes" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will a student understand 'JSON data' in this context? Might need a message that aligns more with ui language? 'Table record size' or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or take the wording we landed on before: "The record is too large. The maximum allowable size is #{DatablockStorageRecord::MAX_RECORD_LENGTH} bytes"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohhhh yeah, that was a good error message wasn't it 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WOOOOOOOOOOOOOOOOOOO so many issues fixed!!!!!!!!!!!!!!!!!!!!!!!!!!!!! amazing!!!!!!!!!!!
Couple small things and otherwise LGTM!