-
-
Notifications
You must be signed in to change notification settings - Fork 272
[#1006][FIX] Add type validation in custom attribute parser to preven… #1008
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
base: master
Are you sure you want to change the base?
Conversation
…to prevent 500 error
WalkthroughBug fix in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
source/app/datamgmt/manage/manage_attribute_db.py (1)
297-303: Duplicateelifblock — lines 301-303 are unreachable dead code.There are two identical
elif field_type in ['raw', 'html']:conditions. The second block (lines 301-303) will never execute. Additionally, lines 301-303 still use the olddata[tab][field]pattern instead of_field_content, indicating this is likely a copy-paste artifact from the refactoring.Remove the duplicate block:
🐛 Proposed fix
elif field_type in ['raw', 'html']: if _field_content.get('value') is None: logs.append(f'{tab} -> {field} of type {field_type} is missing mandatory "value" tag') - elif field_type in ['raw', 'html']: - if data[tab][field].get('value') is None: - logs.append(f'{tab} -> {field} of type {field_type} is missing mandatory "value" tag') - else: logs.append(f'{tab} -> {field}, unknown field type "{field_type}"')
🤖 Fix all issues with AI agents
In @source/app/datamgmt/manage/manage_attribute_db.py:
- Around line 288-290: The error message inside the options type check uses the
wrong variable; when validating if not isinstance(_field_content.get('options'),
list) update the logs.append call in that branch to reference the actual options
value (use type(_field_content.get('options')).__name__) so the message reads
that the field expects a list but got the type of options, keeping the existing
context variables field and field_type.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
source/app/datamgmt/manage/manage_attribute_db.py
🔇 Additional comments (2)
source/app/datamgmt/manage/manage_attribute_db.py (2)
241-245: LGTM! Good defensive check for tab structure.This correctly guards against the issue reported in #1006 where
.get()was called on a non-dict value.
247-253: LGTM! Proper field validation with clear variable naming.Using
_field_contentimproves readability and the type check prevents theAttributeErrorthat caused the 500 error.
| if not isinstance(_field_content.get('options'), list): | ||
| logs.append(f'{tab} -> {field} of type {field_type} expects a value of type list, ' | ||
| f'but got {type(data[tab][field]["value"])}') | ||
| f'but got {type(_field_content.get("value")).__name__}') |
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.
Bug: Wrong variable used in error message for options type check.
Line 290 reports type(_field_content.get("value")) but the check on line 288 is validating _field_content.get('options'). The error message should reference options, not value.
🐛 Proposed fix
if not isinstance(_field_content.get('options'), list):
logs.append(f'{tab} -> {field} of type {field_type} expects a value of type list, '
- f'but got {type(_field_content.get("value")).__name__}')
+ f'but got {type(_field_content.get("options")).__name__}')🤖 Prompt for AI Agents
In @source/app/datamgmt/manage/manage_attribute_db.py around lines 288 - 290,
The error message inside the options type check uses the wrong variable; when
validating if not isinstance(_field_content.get('options'), list) update the
logs.append call in that branch to reference the actual options value (use
type(_field_content.get('options')).__name__) so the message reads that the
field expects a list but got the type of options, keeping the existing context
variables field and field_type.
Description
This PR fixes a critical 500 Internal Server Error when saving or updating Custom Attributes via the UI, as reported in #1006.
Changes
validate_attributewithinapp/datamgmt/manage/manage_attribute_db.py..get().logslist if the JSON structure is invalid._field_contentfor better readability and compliance with project coding rules.Verification Results
Fixes #1006
Summary by CodeRabbit
New Features
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.