Skip to content

Fix CommodityClassification reader to support CommodityCode element#167

Merged
brtdv merged 1 commit intomasterfrom
Fix/commodity-classification-reader
Feb 6, 2026
Merged

Fix CommodityClassification reader to support CommodityCode element#167
brtdv merged 1 commit intomasterfrom
Fix/commodity-classification-reader

Conversation

@brtdv
Copy link
Copy Markdown
Contributor

@brtdv brtdv commented Feb 6, 2026

Summary

  • Fixes warning "Trying to access array offset on null" when reading UBL files with CommodityCode instead of ItemClassificationCode
  • The UBL CommodityClassification element can contain either ItemClassificationCode or CommodityCode, but the reader only supported the former
  • Adds null-check to prevent warnings when neither element is present

Changes

  • Added fallback to CommodityCode when ItemClassificationCode is not found
  • Added null-check before accessing array values
  • Added null-coalescing for the value property

Test plan

  • Verified parsing of UBL files containing CommodityCode elements
  • No warnings produced during parsing
  • CommodityCode values are correctly extracted

The UBL CommodityClassification can contain either ItemClassificationCode
or CommodityCode. The reader only looked for ItemClassificationCode,
causing warnings when parsing XML files that use CommodityCode instead.

This fix:
- Adds fallback to CommodityCode when ItemClassificationCode is not found
- Adds null-check to prevent warnings when neither element is present
- Adds null-coalescing for the value to handle edge cases
@brtdv brtdv merged commit a0fc514 into master Feb 6, 2026
5 checks passed
@brtdv brtdv deleted the Fix/commodity-classification-reader branch February 6, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant