Conversation
Add nested organization collection mode and `--no-folder` support so imports can target organization collections without creating personal folders. Closes #33.
org imports double-file (folderId + collectionIds); folders only duplicate the collection tree in the personal vault, so default them off when an org is set. --folder (BooleanOptionalAction) / KP2BW_CREATE_FOLDERS=1 restores them. - cli: org-aware create_folders default; --no-folder -> --folder/--no-folder - convert: note legacy-claim folder mismatch under --no-folder - docs+test: org default-off behavior ref #33
📝 WalkthroughWalkthroughVersion 3.7.0 adds two related features to sort out the mess of personal folders versus collections. First, Sequence DiagramsequenceDiagram
participant User as User CLI
participant Parser as Argument Parser
participant Resolver as _resolve_bool_option
participant Converter as Converter
participant BatchClient as BitwardenServeClient
User->>Parser: --bitwarden-org <org> [--folder]
Parser->>Resolver: resolve create_folders (default: not bw_org)
Resolver-->>Parser: create_folders boolean
Parser->>Converter: Converter(..., create_folders=create_folders)
Converter->>BatchClient: create_items_batch(..., create_folders=create_folders)
alt create_folders = True
BatchClient->>BatchClient: collect folder names
BatchClient->>BatchClient: create folders in personal vault
BatchClient->>BatchClient: bind folderId to items
else create_folders = False
BatchClient->>BatchClient: skip folder operations
BatchClient->>BatchClient: bind folderId = None
end
BatchClient->>BatchClient: create items with collection IDs applied
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 6 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
📦 Test this PR (archived)
This PR has been merged. You can still test the final state: uvx -p 3.14 --from 'git+https://github.com/kjanat/kp2bw@3045bd7aa33c4ebc7f6e4cef83520580014fc4c8' kp2bw --help📋 PR Details
Merge commit: 3045bd7 📋 Example usage# Show version
uvx -p 3.14 --from 'git+https://github.com/kjanat/kp2bw@3045bd7aa33c4ebc7f6e4cef83520580014fc4c8' kp2bw --version
# Migrate KeePass DB (interactive password prompts)
uvx -p 3.14 --from 'git+https://github.com/kjanat/kp2bw@3045bd7aa33c4ebc7f6e4cef83520580014fc4c8' kp2bw vault.kdbx
# Non-interactive with env vars
KP2BW_KEEPASS_PASSWORD=kppass KP2BW_BITWARDEN_PASSWORD=bwpass uvx -p 3.14 --from 'git+https://github.com/kjanat/kp2bw@3045bd7aa33c4ebc7f6e4cef83520580014fc4c8' kp2bw vault.kdbx -y🤖 Archived on merge |
ty 0.0.51 widens an unannotated {**os.environ} after env.pop(), so
subprocess.Popen's overload stops resolving to Popen[bytes]. Annotate
env: dict[str, str] to keep it stable.
Also address CodeRabbit: _uris returns list[tuple[str, UriMatchValue]],
not object.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Closes #33.
Bitwarden has no "org folder" — the org-side equivalent of a folder is a collection, and nesting is just a
/-naming convention. So an org import today double-files: items land in the org collection and a redundant personal-folder tree gets built on top.What this does
--bitwarden-collection nested— derive collections from the full KeePass path (Work/Servers) instead ofauto's top-level-only segment (Work). Bitwarden renders the/as nested collections.--folder/--no-folder(KP2BW_CREATE_FOLDERS) — toggle personal-folder creation. Default is on, but off when--bitwarden-orgis set, so org imports are collections-only unless--folderopts back in.Both are opt-in and non-breaking for personal-vault imports. The only behavior change is org imports no longer also build a personal folder tree (the exact complaint in #33).
Idempotency
KP2BW_IDstamp (folder-independent).Notes
/creates accidental nesting (pre-existing in folder mode too).Tests
nestedmode uses the full path;autostays top-level only--no-folderbatch creates items withfolderId=Noneand never callscreate_folder--bitwarden-orgflips the personal-folder default off; no org keeps it onKP2BW_CREATE_FOLDERS=0env overrideAll script tests +
ruff+ty+dprintclean.