Omit array-based keys that are empty for assets - #694
Merged
Merged
Conversation
- Adds a new method, serializeArrayField, to parent class, StixObject - The method conditionally serializes an array field to the target object only if it contains at least one element - Modifies Asset SDO to ensure that empty arrays are never included in the serialized STIX object sent to backend - Only effects fields explicitly handled by the Asset SDO, not common fields inherited from StixObject Tested E2E workflow and confirmed the POSTed request body no longer contain empty arrays
elucchesileon
approved these changes
Oct 21, 2025
| protected serializeArrayField( | ||
| target: any, | ||
| key: string, | ||
| value: any[], |
Contributor
There was a problem hiding this comment.
Could this use generics instead of any, just so we can make sure the types match?
protected serializeArrayField<T>(target: any, key: string, value: T[], transform? (val: T[]) => T)
… for better type hinting
clemiller
approved these changes
Oct 22, 2025
|
🎉 This PR is included in version 4.6.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
seansica
added a commit
that referenced
this pull request
Mar 19, 2026
…ssets-serialization Omit array-based keys that are empty for assets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses mitre-attack/attack-workbench-rest-api#430 for fields explicitly managed by assets
Complementary change for backend PR mitre-attack/attack-workbench-rest-api#431
This change ensures that array-based fields explicitly managed by the Asset SDO stop defaulting to empty lists when they are serialized during POST and PUT operations. Instead, array-based fields will be omitted.