Radicale icon indicating copy to clipboard operation
Radicale copied to clipboard

missing FN: causes server error 500:

Open chriscamacho opened this issue 6 years ago • 7 comments

how the wife managed to save a contact without a name, I don't know, I didn't realise you could with Android! (using DavDroid as sync provider)

anyhow if any address book record is missing an FN field you can no longer sync

the fix involves the wife pestering her technical support (me!) who has to shut down radicale, change the logging to debug, find the vdf that's at fault and manually editing it so radicale can serve data.

even if a VCARD or VCAL entry is invalid, its not really for the server to police this as there is no real mechanism to feedback to the end user, permanently causing a 500 error isn't very useful.

I seem to remember I've had similar issues to this previously

chriscamacho avatar May 27 '18 15:05 chriscamacho

Can you please share a traceback from the radicale server when reproducing the bug? This would be important to fix the issue.

genodeftest avatar May 28 '18 07:05 genodeftest

it does actually look like an exception fortunatly it doesn't bring the whole thing down!

[7fb560069700] ERROR: An exception occurred during GET request on '/chris/AddressBook.vcf/': Failed to load item 'f9cacb1d-751d-48a4-b7ad-936380ce7203.vcf' in 'chris/AddressBook.vcf': 'VCARD components must contain at least 1 FN'
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/radicale/storage.py", line 1400, in _get_with_metadata
    href, vobject_item, input_hash)
  File "/usr/lib/python3.6/site-packages/radicale/storage.py", line 1277, in _store_item_cache
    content = self._item_cache_content(href, vobject_item, cache_hash)
  File "/usr/lib/python3.6/site-packages/radicale/storage.py", line 1265, in _item_cache_content
    text = vobject_item.serialize()
  File "/usr/lib/python3.6/site-packages/vobject/base.py", line 254, in serialize
    return behavior.serialize(self, buf, lineLength, validate)
  File "/usr/lib/python3.6/site-packages/vobject/behavior.py", line 157, in serialize
    cls.validate(obj, raiseException=True)
  File "/usr/lib/python3.6/site-packages/vobject/behavior.py", line 93, in validate
    raise base.ValidateError(m .format(cls.name, val[0], key))
vobject.base.ValidateError: 'VCARD components must contain at least 1 FN'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/radicale/__init__.py", line 323, in __call__
    status, headers, answers = self._handle_request(environ)
  File "/usr/lib/python3.6/site-packages/radicale/__init__.py", line 496, in _handle_request
    environ, base_prefix, path, user)
  File "/usr/lib/python3.6/site-packages/radicale/__init__.py", line 622, in do_GET
    "ETag": item.etag}
  File "/usr/lib/python3.6/site-packages/radicale/storage.py", line 1534, in etag
    self._etag_cache = super().etag
  File "/usr/lib/python3.6/site-packages/radicale/storage.py", line 492, in etag
    for item in self.get_all():
  File "/usr/lib/python3.6/site-packages/radicale/storage.py", line 1438, in <genexpr>
    return (self.get(href, verify_href=False) for href in self.list())
  File "/usr/lib/python3.6/site-packages/radicale/storage.py", line 1255, in get
    item, metadata = self._get_with_metadata(href, verify_href=verify_href)
  File "/usr/lib/python3.6/site-packages/radicale/storage.py", line 1403, in _get_with_metadata
    (href, self.path, e)) from e
RuntimeError: Failed to load item 'f9cacb1d-751d-48a4-b7ad-936380ce7203.vcf' in 'chris/AddressBook.vcf': 'VCARD components must contain at least 1 FN'

I tried with adding just above N: a line containing only 3 characters FN: and that was enough to allow the server to work

chriscamacho avatar May 28 '18 09:05 chriscamacho

@chriscamacho : Please use styling with markdown to make the traceback more readable.

According to the vCard standard, any vcard file must contain a "FN" which is the name of a contact. It looks like some code on the android phone does not comply to this specification.

genodeftest avatar May 28 '18 09:05 genodeftest

of course its not following the standard and is erroneous data this is NOT the issue

as the server has no way to feedback this to the end user, it shouldn't just give up and make the service unusable until someone can go in and manually edit the data

exceptions from third party libraries must be handled properly - at the very least throw a big error message server response you could see in the davdroid debug log, but once it get to this point there is nothing you can do from android you have to go to the server via SSH to fix it... so even if it continued serving this would be a less than idea solution

to be robust you must test with invalid input and make sure it at least does save data that later stops it serving for that collection.

I've already suggested a workaround for this specific exception, I would guess there are a number of other exceptions vobject can/will throw

chriscamacho avatar May 28 '18 09:05 chriscamacho

I also ran into this. I sometimes use this for companies: I then fill in the company/organization field, leaving the name empty.

I ran into this problem when trying to import my complete address book, which enlarges the problem, as it prevents the entire vcf file from being imported.

Also, the error message is quite concise, the webui only says "Error: 400 Bad Request", while the log only says " Failed to serialize item None from 'username/123-456': VCARD components must contain at least 1 FN", with no reference about which contact was problematic (maybe because it prints the FN, which is None?).

The vcf file I was importing was exported by Google Contacts.

matthijskooijman avatar May 15 '21 21:05 matthijskooijman

I also think Radicale should handle this issue - it is still failing to save contacts without FN. Emails that don't have a sender name are still fairly common, and perhaps just a default value for FN could be established?

neilromig avatar Jan 25 '22 06:01 neilromig

Radicale 2+ uses external library "vobject" as VCF/ICS parser, one can develop a tool which checks each file on server for validity. Potential this validity check tool can optionally also try to catch the error message and try to turn the input VCF/ICS in an accepted one add/modify.

pbiering avatar Jul 03 '23 05:07 pbiering