fix ProfileDataField.UnmarshalJSON to accept null#645
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe PR modifies ChangesProfileDataField Null Handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
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🧪 Generate unit tests (beta)
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.
🧹 Nitpick comments (1)
armotypes/runtimerule_profile_data_test.go (1)
92-98: ⚡ Quick winAdd a parallel BSON null test to cover the symmetric
UnmarshalBSONValuechange.
TestProfileDataField_UnmarshalJSON_AcceptsNullcovers the JSON path, but thebsontype.Nullearly-return added toUnmarshalBSONValuehas no test. A BSON null can arrive from MongoDB when a document field is explicitly set tonull.🧪 Suggested test
func TestProfileDataField_UnmarshalBSONValue_AcceptsNull(t *testing.T) { var f ProfileDataField err := f.UnmarshalBSONValue(bsontype.Null, nil) assert.NoError(t, err) assert.False(t, f.All) assert.Nil(t, f.Patterns) }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@armotypes/runtimerule_profile_data_test.go` around lines 92 - 98, Add a parallel BSON null unit test to cover the new bsontype.Null early-return in UnmarshalBSONValue: create TestProfileDataField_UnmarshalBSONValue_AcceptsNull that declares var f ProfileDataField, calls f.UnmarshalBSONValue(bsontype.Null, nil), asserts no error, asserts f.All is false and f.Patterns is nil; this mirrors TestProfileDataField_UnmarshalJSON_AcceptsNull to ensure BSON nulls from MongoDB are handled.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@armotypes/runtimerule_profile_data_test.go`:
- Around line 92-98: Add a parallel BSON null unit test to cover the new
bsontype.Null early-return in UnmarshalBSONValue: create
TestProfileDataField_UnmarshalBSONValue_AcceptsNull that declares var f
ProfileDataField, calls f.UnmarshalBSONValue(bsontype.Null, nil), asserts no
error, asserts f.All is false and f.Patterns is nil; this mirrors
TestProfileDataField_UnmarshalJSON_AcceptsNull to ensure BSON nulls from MongoDB
are handled.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a5b768ca-405e-4f37-aee2-ed1427099532
📒 Files selected for processing (2)
armotypes/runtimerule.goarmotypes/runtimerule_profile_data_test.go
There was a problem hiding this comment.
Pull request overview
This PR updates ProfileDataField decoding to tolerate null values during JSON and BSON unmarshalling, aligning it with optional/absent semantics that can appear in stored documents or payloads.
Changes:
- Allow
ProfileDataField.UnmarshalJSONto acceptnullwithout error. - Allow
ProfileDataField.UnmarshalBSONValueto accept BSONNullwithout error. - Update the unit test to expect
nullJSON unmarshalling to succeed.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
armotypes/runtimerule.go |
Adjusts JSON and BSON unmarshalling for ProfileDataField to accept null inputs. |
armotypes/runtimerule_profile_data_test.go |
Updates JSON null unmarshalling test to expect success and verify resulting state. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage Report for CI Build 25481752728Warning No base build found for commit Coverage: 43.199%Details
Uncovered Changes
Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
Summary by CodeRabbit