Skip to content

Commit

Permalink
🔀 Merge pull request #61 from davep/handle-orphan-collection
Browse files Browse the repository at this point in the history
Fix crash when given a child collection sans parent
  • Loading branch information
davep authored Jan 9, 2025
2 parents 5312ea8 + e8e588d commit b4dd4d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
([#53](https://github.com/davep/braindrop/pull/53))
- Notes are now rendered as a Markdown document.
([#60](https://github.com/davep/braindrop/pull/60))
- Fixed a crash caused by Raindrop sometimes including collections without
parents in the list of child collections.
([#61](https://github.com/davep/braindrop/pull/61))

## v0.3.0

Expand Down
8 changes: 7 additions & 1 deletion src/braindrop/raindrop/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ def from_json(data: dict[str, Any]) -> Collection:
sort=data.get("sort", 0),
title=data.get("title", ""),
view=data.get("view", ""),
parent=data.get("parent", {}).get("$id"),
# The rather awkward defaulting here comes from the fact that
# the Raindrop API seems to include a child collection that has
# been moved to the top-level in the list of child collections;
# but has its `parent` be `null` -- not even an empty object.
# This feels like a bug in Raindrop, or at least in its API.
# This works around that.
parent=(data.get("parent") or {}).get("$id"),
)


Expand Down

0 comments on commit b4dd4d8

Please sign in to comment.