Skip to content

Fix structured data for Radicale 3.6.1#38

Open
DiagonalArg wants to merge 7 commits into
39aldo39:masterfrom
DiagonalArg:fix-structured-data
Open

Fix structured data for Radicale 3.6.1#38
DiagonalArg wants to merge 7 commits into
39aldo39:masterfrom
DiagonalArg:fix-structured-data

Conversation

@DiagonalArg

Copy link
Copy Markdown

Provides update to make the plugin compatible with Radicale 3.6.1 and Python 3.12.3, by fixing a data-integrity bug involving structured vCard fields. Without the added isinstance check, contacts with structured fields (eg. addresses or names) cause a TypeError during serialization, halting the sync process.

It has been tested working in:

   package radicale 3.6.1, installed using Python 3.12.3
    - radicale
    Injected Packages:
      - radicale_storage_decsync 2.1.0
      - setuptools 79.0.1

It is based on JornJorn's fork, which in turn seems to be based on mab122's.

@m-hobby

m-hobby commented Mar 26, 2026

Copy link
Copy Markdown

Hi @DiagonalArg,

Did a fresh install with
radicale 3.6.1 (Python 3.12.3)
radicale_storage_decsync 2.1.0 (fix-structured-data branch)
setuptools 79.0.1

During initial setup / login of the admin user, ran into another tuple error on discover().
Here is the patch.

Apart from that things were working well, so thanks for your help.

DiagonalArg#1

Fix discover() tuple unpacking for Radicale 3

Thanks @m-hobby
@DiagonalArg

Copy link
Copy Markdown
Author

Updated this PR to include the fix contributed by @m-hobby. This addresses an issue where certain collection metadata was causing synchronization failures in recent Radicale 3.x releases.

Technical Note: The fix ensures that the storage provider correctly handles the Item object initialization during the sync process, preventing potential AttributeError or NoneType crashes when DecSync attempts to map local files to Radicale's internal collection structure.

self.set_href(item.uid, href)
# Ensure structured data (lists/tuples) are stringified before serialization
for component in item.vobject_item.getChildren():
if isinstance(component.value, (list, tuple)):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hello!

Thank you for your PR, and also @39aldo39, thank you for the original plugin!

On this very line sometimes the component.value field does not seem to get populated for me, resulting in 500 ISE. With a quick hack, I found a way to get past this:

   component_value = getattr(component, 'value', None)
   if isinstance(component_value, (list, tuple)):

So far it seems working, hope it does not break anything.

Just wanted to jot that down somewhere not to lose it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For improved Google-ability, this is what the exception looks like in the logs:

[ERROR] Traceback (most recent call last):
   File "/usr/lib/python3.13/site-packages/vobject/base.py", line 533, in __getattr__
     return self.contents[toVName(name)][0]
            ~~~~~~~~~~~~~^^^^^^^^^^^^^^^
 KeyError: 'value'
 
 During handling of the above exception, another exception occurred:
 
 Traceback (most recent call last):
   File "/usr/lib/python3.13/site-packages/radicale/app/__init__.py", line 613, in _handle_request
     status, headers, answer, xml_request = function(
                                            ~~~~~~~~^
         environ, base_prefix, path, user, remote_host, remote_useragent)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/usr/lib/python3.13/site-packages/radicale/app/put.py", line 353, in do_PUT
     uploaded_item, replaced_item = parent_item.upload(href, prepared_item)
                                    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
   File "/usr/local/lib/python3.13/site-packages/radicale_storage_decsync/__init__.py", line 112, in upload
     if isinstance(component.value, (list, tuple)):         
                   ^^^^^^^^^^^^^^^
   File "/usr/lib/python3.13/site-packages/vobject/base.py", line 535, in __getattr__
     raise AttributeError(name)
 AttributeError: value

@DiagonalArg

Copy link
Copy Markdown
Author

@kuklinistvan / please see my new PR, here:
#40

Also, note that I am doing maintenance on my repo. You and others are welcome to report issues there:
https://github.com/DiagonalArg/Radicale-DecSync

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.

4 participants