Skip to content

make sure app_data is bytes, not str#3

Draft
jardous wants to merge 1 commit intofr33n0w:mainfrom
jardous:main
Draft

make sure app_data is bytes, not str#3
jardous wants to merge 1 commit intofr33n0w:mainfrom
jardous:main

Conversation

@jardous
Copy link
Copy Markdown

@jardous jardous commented Mar 15, 2026

Bugfix

LXMF.display_name_from_app_data() internally calls .decode() on its argument, which only works on bytes. In newer versions of RNS/LXMF, app_data can arrive (or be recalled) as a str instead of bytes, triggering the 'str' object has no attribute 'decode' error.

@jardous jardous marked this pull request as draft March 15, 2026 20:05
@jardous
Copy link
Copy Markdown
Author

jardous commented Mar 15, 2026

does not really solve the issue :/

[DEBUG] Received announce from with app_data: b'\x91\xa5Ditch'
[2026-03-15 21:01:18] [Error] Could not decode display name in included announce data. The contained exception was: 'str' object has no attribute 'decode'

Happens here:

    def register_announce_handler(self):
        """Register handler to capture display names from announces"""
        
        class LXMFPeerAnnounceHandler:
            def __init__(self, client):
                self.client = client
                self.aspect_filter = "lxmf.delivery"
            
            def received_announce(self, destination_hash, announced_identity, app_data):
                """Called when an LXMF delivery announce is received"""
                try:
                    if app_data:
                        print(f"\n[DEBUG] Received announce from {RNS.prettyhexrep(destination_hash)} with app_data: {app_data}")
                        if isinstance(app_data, str):
                            app_data = app_data.encode('utf-8')
                        display_name = LXMF.display_name_from_app_data(app_data)
                        
                        if display_name and isinstance(display_name, str):
                            hash_str = RNS.prettyhexrep(destination_hash)
                            clean_hash = hash_str.replace(":", "").replace(" ", "").lower()

@jardous
Copy link
Copy Markdown
Author

jardous commented Mar 15, 2026

ok - fixed the issue: https://github.com/markqvist/LXMF/compare/master...jardous:patch-1?expand=1

But no idea how to PR... :/

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