Bug: CardDav fails to save changes to google, if name is not set on the card
Status: RESOLVED
Priority: --
Resolution: FIXED
Created: 2022-09-22 22:17:10+00:00
Resolved: 2022-10-14 00:13:33+00:00

Steps to reproduce:

When setting up a new CardDav address book, changes fail to save back to the server due to 400 Bad Request.

This is on Thunderbird 102.1.2.

Here's an example from the error console:

```
PUT
https://www.googleapis.com/carddav/v1/principals/phil@ipom.com/lists/default/363986d2-6b5a-468f-8010-d5f9d0603b99.vcf
[HTTP/2 400 Bad Request 90ms]

	
PUT
	https://www.googleapis.com/carddav/v1/principals/phil@ipom.com/lists/default/363986d2-6b5a-468f-8010-d5f9d0603b99.vcf
Status
400
Bad Request
VersionHTTP/2
Transferred630 B (127 B size)

    	
    alt-svc
    	h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
    cache-control
    	private
    content-encoding
    	gzip
    content-length
    	129
    content-type
    	application/json; charset=UTF-8
    date
    	Thu, 22 Sep 2022 22:12:04 GMT
    server
    	ESF
    vary
    	Origin
    vary
    	X-Origin
    vary
    	Referer
    x-content-type-options
    	nosniff
    X-Firefox-Spdy
    	h2
    x-frame-options
    	SAMEORIGIN
    x-xss-protection
    	0
    	
    Accept
    	*/*
    Accept-Encoding
    	gzip, deflate, br
    Accept-Language
    	en-US,en;q=0.5
    Authorization
    	Bearer XXXXX
    Connection
    	keep-alive
    Content-Length
    	131
    Content-Type
    	text/vcard
    Host
    	www.googleapis.com
    Origin
    	https://www.googleapis.com
    Sec-Fetch-Dest
    	empty
    Sec-Fetch-Mode
    	no-cors
    Sec-Fetch-Site
    	same-origin
    TE
    	trailers
    User-Agent
    	Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.1.2
```

Here's another example:

```
PUThttps://www.googleapis.com/carddav/v1/principals/phil@ipom.com/lists/default/0037b4e4-f4e3-4e4a-9a88-b8543dc4aa50.vcf
[HTTP/2 400 Bad Request 87ms]

	
PUT
	https://www.googleapis.com/carddav/v1/principals/phil@ipom.com/lists/default/0037b4e4-f4e3-4e4a-9a88-b8543dc4aa50.vcf
Status
400
Bad Request
VersionHTTP/2
Transferred630 B (127 B size)

    	
    alt-svc
    	h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
    cache-control
    	private
    content-encoding
    	gzip
    content-length
    	129
    content-type
    	application/json; charset=UTF-8
    date
    	Thu, 22 Sep 2022 22:12:04 GMT
    server
    	ESF
    vary
    	Origin
    vary
    	X-Origin
    vary
    	Referer
    x-content-type-options
    	nosniff
    X-Firefox-Spdy
    	h2
    x-frame-options
    	SAMEORIGIN
    x-xss-protection
    	0
    	
    Accept
    	*/*
    Accept-Encoding
    	gzip, deflate, br
    Accept-Language
    	en-US,en;q=0.5
    Authorization
    	Bearer XXXX
    Connection
    	keep-alive
    Content-Length
    	139
    Content-Type
    	text/vcard
    Host
    	www.googleapis.com
    Origin
    	https://www.googleapis.com
    Sec-Fetch-Dest
    	empty
    Sec-Fetch-Mode
    	no-cors
    Sec-Fetch-Site
    	same-origin
    TE
    	trailers
    User-Agent
    	Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.1.2
```

There's also this error after the bad requests:

```
[Exception... "Sending card to the server failed, response was 400 Bad Request"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: resource:///modules/CardDAVDirectory.jsm :: _sendCardToServer :: line 400"  data: no] 4 CardDAVDirectory.jsm:400:24
    _sendCardToServer resource:///modules/CardDAVDirectory.jsm:400
    InterpretGeneratorResume self-hosted:1422
    AsyncFunctionNext self-hosted:632
```


Actual results:

400, bad request, see above.


Expected results:

200, and a saved card.