mirror of
https://github.com/ciur/papermerge.git
synced 2026-04-25 12:05:58 +03:00
[GH-ISSUE #302] Mail import fails with TypeError #240
Labels
No labels
2.1
3.0
3.0.1
3.0.2
3.0.3
3.0.3
3.1
3.2
3.2
3.3
3.5
3.x
Fixed. Waiting for feedback.
Fixed. Waiting for feedback.
UX
Version 2.1 - alpha
XSS
announcement
beta
blocker
bug
cannot reproduce
confirmed
confirmed
critical
demo
dependencies
deployment
detchnical debt
discussion
docker
documentation
donations
duplicate
enhancement
feature request
frontend
fundraising
good first issue
good issue
help wanted
high
implemented
important
improvement
incomplete
invalid
investigation
kubernetes
low
low impact
medium
medium
medium impact
migration from 2.0
migration from 2.1
missing-language
missing-ocr-language
no-activity
note
ocr
outofscope
packaging
performance
popular request
pull-request
pypi
question
raspberry pi
roadmap
search
security
setup
status
task
technical debt
updates
user xp
version 1.4.0 - demo
will be implemented
will not be implemented
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/papermerge#240
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @napcae on GitHub (Feb 11, 2021).
Original GitHub issue: https://github.com/ciur/papermerge/issues/302
Originally assigned to: @ciur on GitHub.
In case you experience issues with docker image provided by linuxserver.io/papermerge, please open bug report in their repository.
Description
I've tried to setup a basic IMAP importer. Running on the supplied docker images, I've set
config/worker.production.py
(This is another bug maybe, if I set the vars without the PAPERMERGE_ prefix, the app is complaining in app.log that the vars are not set and therefore no IMAP importer will be configured.)
RAW Mail
Expected
An imported document via IMAP.
Actual
No documents are imported:
Info:
@ciur commented on GitHub (Feb 12, 2021):
@napcae, I think the problem here is fastmail's name of IMAP inbox folder is "Inbox" (i.e. capitalized) instead of Papermerge's default value of "INBOX" (all uppercase).
Try setting option
PAPERMERGE_IMPORT_MAIL_INBOXto:i.e. Capitalized.
It is a valid bug anyway, because (Papermerge) application should provide proper feedback when it cannot select IMAP inbox folder. Thank you for opening this ticket!
@napcae commented on GitHub (Feb 13, 2021):
Hey @ciur, thanks for taking a look. I don't think that's the problem though, I've started with a (imap) folder called "papermerge", i.e.
PAPERMERGE_IMPORT_MAIL_INBOX = "papermerge"and still had the same error.I've just tried
PAPERMERGE_IMPORT_MAIL_INBOX = "Inbox"and the same error comes up:Unless TypeError is a red herring, I'd suspect something different than capitalization be the problem, no?
Edit:
Listing imap folders shows that the default name is
INBOXas well:@napcae commented on GitHub (Feb 13, 2021):
So I was digging a little bit more, turns out you need RW imap access.
For testing purposes I had created a RO user which leads to the failure.
According to rfc3501, Section 6.4.5:
Assuming fastmail implemented this per spec, that is the culprit.
I've verified my hypothesis by setting
readonly=true:github.com/napcae/papermerge@04f09dbb14/papermerge/core/importers/imap.py (L121-L124)The importer won't crash but will import mails indefinitely since it won't set the read flag on the (imap) server.
How do you want to fix this? I'm not too familiar with python to fix this upstream(in imapclient), but an exception catch might be enough, wdyt @ciur ?
@ciur commented on GitHub (Feb 13, 2021):
@napcae, I think that wrapping server.select_folder(...) into a
try ... exceptblock withlogging.error(<error + explanation what may be the cause of it and what user can do to fix it>)will suffice.Going with
readonly=TrueIMHO defeats the purpose of fetching documents from IMAP account.If you go on with above fix please don't forget to update documentation. with your findings that IMAP account requires RW access and there will be XYZ warning otherwise.
@napcae commented on GitHub (Feb 13, 2021):
I'm aware, the explanation was for demonstration purpose only
One more thing, I mentioned it in my first post - the worker won't recognize mail configuration directives for mail, i.e.
IMPORT_MAIL_HOST,IMPORT_MAIL_USERetc. without thePAPERMERGEprefix. Is the documentation out of that or what is it that I'm missing here?@ciur commented on GitHub (Feb 13, 2021):
@napcae
Yes. There is difference where you place those settings. Settings can be either in:
In
papermerge.conf.pyfile configuration settings are withoutPAPERMERGE_prefix, because all (well, 90%) of them are papermerge specific.In django settings file however, there are all sort of settings - for celery (prefixed with CELERY_), for allauth (prefixed with ACCOUNT_). Respectively settings for specific for papermerge are prefixed as well.
You are right that above information would be great addition to the documentation. In fact I just updated and deployed documentation based on above explanation :)
@napcae commented on GitHub (Feb 13, 2021):
Alright, thanks for clarification and updating the documentation. I've opened a PR as you can see above this comment. It won't fix the issue but at least it spits out some useful information for the user/administrator.