Skip to content
New issue

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

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

Already on GitHub? # to your account

Disqus import failing if there are threads without titles #728

Closed
waqqasdadabhoy opened this issue May 18, 2021 · 2 comments · Fixed by #855
Closed

Disqus import failing if there are threads without titles #728

waqqasdadabhoy opened this issue May 18, 2021 · 2 comments · Fixed by #855
Labels
bug feature good-first-issue Help welcome! needs-contributor Someone needs to implement this. Help wanted!
Milestone

Comments

@waqqasdadabhoy
Copy link

I'm getting the following error while importing a Disqus file:

Traceback (most recent call last):
  File "/usr/bin/isso", line 11, in <module>
    load_entry_point('isso==0.12.2', 'console_scripts', 'isso')()
  File "/usr/lib/python3/dist-packages/isso/__init__.py", line 249, in main
    migrate.dispatch(args.type, mydb, args.dump, args.empty_id)
  File "/usr/lib/python3/dist-packages/isso/migrate.py", line 367, in dispatch
    cls(db, dump).migrate()
  File "/usr/lib/python3/dist-packages/isso/migrate.py", line 137, in migrate
    self.insert(thread, res[id])
  File "/usr/lib/python3/dist-packages/isso/migrate.py", line 87, in insert
    self.db.threads.new(path, thread.find(
AttributeError: 'NoneType' object has no attribute 'strip'

I found that it occurs because there are some threads in the XML file without titles:

<thread dsq:id="1079336008">
<id />
<forum>redacted</forum>
<category dsq:id="435915" />
<link>http://localhost:4000/blog/2013/02/12/redacted/index.html</link>
<title />
<message />
<createdAt>2013-02-12T16:29:45Z</createdAt>
<author>
<name>Redacted</name>
<isAnonymous>false</isAnonymous>
<username>redacted</username>
</author>
<isClosed>false</isClosed>
<isDeleted>false</isDeleted>
</thread>

I have found that changing lines 87-88 in migrate.py to the following, to convert the None to an empty string, to convert the None to an empty string, fixes the problem (not being a Python programmer, I'm not sure if this is a proper solution):

            thread_title = thread.find(Disqus.ns + 'title').text or ''
            self.db.threads.new(path, thread_title.strip())
@ix5
Copy link
Member

ix5 commented Dec 21, 2021

Nicely done! Would you mind submitting a Pull Request for your solution?

It seems that same "fix" would also be applicable to the WordPress and Generic importers.

My stylistic preference would be:

thread_title = thread.find(Disqus.ns + 'title').text.strip() or ""
self.db.threads.new(path, thread_title)

Though I tend to prefer "Imported Thread" or some other default instead of just an empty string. Open to discussions...

If you like, creating a test case for your Disqus import (missing/empty titles) would also be appreciated.

@ix5 ix5 added bug feature needs-contributor Someone needs to implement this. Help wanted! labels Dec 27, 2021
@ix5 ix5 added this to the 0.13 milestone Feb 13, 2022
@ix5 ix5 added the good-first-issue Help welcome! label Apr 23, 2022
ix5 added a commit to ix5/isso that referenced this issue May 1, 2022
ix5 added a commit to ix5/isso that referenced this issue May 1, 2022
@ix5
Copy link
Member

ix5 commented May 1, 2022

Tracked in #855

@ix5 ix5 closed this as completed May 1, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug feature good-first-issue Help welcome! needs-contributor Someone needs to implement this. Help wanted!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants