Skip to content

ECC-2220 Fix setting string keys in BUFR messages#154

Closed
oiffrig wants to merge 1 commit intodevelopfrom
fix/ECC-2220-hl-bufr-set-string
Closed

ECC-2220 Fix setting string keys in BUFR messages#154
oiffrig wants to merge 1 commit intodevelopfrom
fix/ECC-2220-hl-bufr-set-string

Conversation

@oiffrig
Copy link
Contributor

@oiffrig oiffrig commented Feb 13, 2026

Description

Setting a single-valued string key in a BUFR message results in the value being truncated, e.g.:

from eccodes import BUFRMessage
bufr = BUFRMessage("BUFR4")
bufr["unexpandedDescriptors"] = [1025]
bufr["stormIdentifier"] = "70A"
assert bufr["stormIdentifier"] == "70A", "Fail before pack()"
bufr.pack()
print("Storm identifier:", bufr["stormIdentifier"])
assert bufr["stormIdentifier"] == "70A", "Fail after pack()"

Fails on the second assert. This fixes the issue to my understanding, but please check it is appropriate as I am not totally familiar with the high-level BUFR interface.

Contributor Declaration

By opening this pull request, I affirm the following:

  • All authors agree to the Contributor License Agreement.
  • The code follows the project's coding standards.
  • I have performed self-review and added comments where needed.
  • I have added or updated tests to verify that my changes are effective and functional.
  • I have run all existing tests and confirmed they pass.

@oiffrig oiffrig requested review from joobog and shahramn February 13, 2026 10:54
@codecov-commenter
Copy link

codecov-commenter commented Feb 13, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 30.01%. Comparing base (46a0885) to head (8e0f2fe).
⚠️ Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
eccodes/highlevel/_bufr/coder.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #154   +/-   ##
========================================
  Coverage    30.01%   30.01%           
========================================
  Files           34       34           
  Lines         6180     6180           
  Branches       743      743           
========================================
  Hits          1855     1855           
  Misses        4296     4296           
  Partials        29       29           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shahramn shahramn requested a review from tomas-kral February 13, 2026 11:32
@shahramn shahramn self-assigned this Feb 13, 2026
@shahramn shahramn added the approved-for-ci Approved for CI label Feb 13, 2026
@tomas-kral
Copy link
Collaborator

tomas-kral commented Feb 13, 2026

Hi @oiffrig, you've just uncovered a bug in my botched attempt at a workaround for an old bug in the eccodes library that had already been fixed quite some time ago (see ECC-1623). My workaround is botched in a sense that it only works correctly for compressed messages (compressedData=1); whereas, as you found out, it doesn't do the right thing when the message is uncompressed (as is the case in your example). Unfortunately, with your change in place, this will now only work correctly for uncompressed messages, and will fail with the compressed ones. :)

In any case, given that the root cause had been resolved since eccodes 2.31.0, which is quite old version by now, I think it's safe to drop the problematic workaround entirely. The generic code that follows after my workaround should now work seamlessly for both compressed and uncompressed messages.

If you are OK with that, I suggest we close this PR, and I will submit a new one with the problematic code removed, and maybe will add some tests as well so that we can catch any issues with this in the future.

How does it sound?

@oiffrig
Copy link
Contributor Author

oiffrig commented Feb 13, 2026

Sounds good to me. Thanks for looking into it!

@oiffrig oiffrig closed this Feb 13, 2026
@shahramn shahramn deleted the fix/ECC-2220-hl-bufr-set-string branch February 14, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved-for-ci Approved for CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants