Skip to content

fix: Handle non-UTF-8 characters in ABNF parser stderr output#626

Merged
kesara merged 1 commit intoietf-tools:mainfrom
1456055067:fix/abnf-unicode-decode-errors
Feb 16, 2026
Merged

fix: Handle non-UTF-8 characters in ABNF parser stderr output#626
kesara merged 1 commit intoietf-tools:mainfrom
1456055067:fix/abnf-unicode-decode-errors

Conversation

@1456055067
Copy link
Contributor

@1456055067 1456055067 commented Feb 16, 2026

Summary

Add errors="ignore" parameter to stderr.decode() calls in the ABNF parser to prevent crashes when BAP tool outputs non-UTF-8 characters.

Changes

  • Modified at/utils/abnf.py:
    • Line 18: Added errors="ignore" to stderr decode in extract_abnf()
    • Line 45: Added errors="ignore" to stderr decode in parse_abnf()

Problem

The application was crashing with UnicodeDecodeError when the BAP (ABNF parser) tool output non-UTF-8 characters in stderr. The stdout decode calls already had errors="ignore" error handling, but stderr decode calls did not.

Example errors:

  • UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 2298
  • UnicodeDecodeError: 'utf-8' codec can't decode byte 0x96 in position 0

Solution

Made stderr decoding consistent with stdout decoding by adding the errors="ignore" parameter. This allows the decoder to skip or replace invalid UTF-8 sequences instead of raising an exception.

Testing

  • Python syntax validation passed
  • All decode calls now consistently use errors="ignore"

Related Issues

Add errors="ignore" parameter to stderr.decode() calls in both
extract_abnf() and parse_abnf() functions to prevent crashes when
the BAP tool outputs non-UTF-8 characters in error messages.

This fixes UnicodeDecodeError exceptions that occurred when stderr
contained invalid UTF-8 bytes (e.g., 0xe2, 0x96). The stdout decode
calls already had this error handling; this change makes stderr
handling consistent.

Fixes ietf-tools#284, Fixes ietf-tools#530
Copy link
Member

@kesara kesara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

@kesara kesara merged commit d1e9cef into ietf-tools:main Feb 16, 2026
2 checks passed
@1456055067 1456055067 deleted the fix/abnf-unicode-decode-errors branch February 17, 2026 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants