Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2: fails to parse imap server response #612

Open
quzhi1 opened this issue Apr 22, 2024 · 2 comments
Open

v2: fails to parse imap server response #612

quzhi1 opened this issue Apr 22, 2024 · 2 comments
Labels
client non-standard Interoperability with software violating the specs

Comments

@quzhi1
Copy link
Contributor

quzhi1 commented Apr 22, 2024

I have seen this error when I try to connect to an imap server:

in response-data: imapwire: expected number, got "]"
exit status 1

I suspect there is some error when parsing the server response. This is my test script that can reproduce this error: https://github.com/quzhi1/ImapPlayground/blob/main/benchmark/idle_v2/main.go#L56. I am not able to select an folder because the client is not able to parse the server response.

I configured DebugWriter: os.Stdout. This is the full response:

✗ go run benchmark/idle_v2/main.go
T1 LOGIN "<redacted>" "<redacted>"
* OK imap server ready for requests
*T2 CAPABILITY
 CAPABILITY IMAP4rev1 MOVE IDLE UTF8=ACCEPT ID ENABLE UIDPLUS
T1 OK LOGIN successfully logged in
* CAPABILITY IMAP4rev1 MOVE IDLE UTF8=ACCEPT ID ENABLE UIDPLUS
T2 OK CAPAT3 CAPABILITY
T4 EXAMINE INBOX
BILITY Completed
* CAPABILITY IMAP4rev1 MOVE IDLE UTF8=ACCEPT ID ENABLE UIDPLUS
T3 OK CAPABILITY Completed
* FLAGS (\DELETED \RECENT \DRAFT \FLAGGED \ANSWERED \SEEN)
* OK [PERMANENTFLAGS (\DELETED \RECENT \DRAFT \FLAGGED \ANSWERED \SEEN)] flags permitted
* OK [UIDVALIDITY 1713632002544]2024/04/22 10:51:57 failed to select Archive: in response-data: imapwire: expected number, got "]"

The email hosting service I am using is https://www.dynadot.com/. I tried to directly use open_ssl to connect to their IMAP server, and their response seems to comply with the IMAP standard. This is their server's response when I select a folder:

a SELECT INBOX
* FLAGS (\DELETED \RECENT \DRAFT \FLAGGED \ANSWERED \SEEN)
* OK [PERMANENTFLAGS (\DELETED \RECENT \DRAFT \FLAGGED \ANSWERED \SEEN)] flags permitted
* OK [UIDVALIDITY 1713632002544] UIDs valid
* 1 EXISTS
* 0 RECENT
* OK [UIDNEXT 2] Predicted next UID
a OK [READ-WRITE] INBOX selected

Is there something wrong this line? https://github.com/emersion/go-imap/blob/v2/imapclient/client.go#L831

Thank you for taking a look 🙏

@emersion emersion added the non-standard Interoperability with software violating the specs label Apr 24, 2024
@emersion
Copy link
Owner

emersion commented Apr 24, 2024

Hm, it seems like they are sending 1713632002544 as UIDVALIDITY, which exceeds the maximum value that a uint32 can store (4294967295).

Our error message is far from ideal here, but not sure how to handle these cases…

@quzhi1
Copy link
Contributor Author

quzhi1 commented Apr 24, 2024

Thank you for taking a look! This makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client non-standard Interoperability with software violating the specs
Projects
None yet
Development

No branches or pull requests

2 participants