Skip to content

Bugs surfaced by core-logic tests (PR #1245) #1246

@chhoumann

Description

@chhoumann

While adding unit tests in #1245, the tests surfaced these suspected bugs. They were deliberately not locked into the tests (the suite asserts correct behavior). Ordered by severity.

Medium

  • quickAddApi.executeChoice proceeds with an undefined choicesrc/quickAddApi.ts:215-228. When plugin.getChoiceByName returns undefined, it calls reportError (which only logs) but then still await choiceExecutor.execute(choice) with choice === undefined instead of returning early. Also the const choice: IChoice annotation is dishonest (value can be undefined). Fix: return after reporting.

Low

  • duplicateChoice drops fields for Multi choicessrc/services/choiceService.ts:42-49. The Multi early-return copies only choices/placeholder/collapsed (+ new name/id); unlike the non-Multi path it doesn't copy command/onePageInput, so duplicating a Multi with command: true yields command: false. Asymmetric vs other choice types.
  • Dead schema-version checksrc/services/packageImportService.ts:114-118. isQuickAddPackage() already requires schemaVersion === CURRENT exactly, so a newer-version package fails validation first and the user gets the generic "not a valid package" error instead of the helpful version-mismatch message.
  • isChoiceImportable cycle guard skips bookkeepingsrc/services/packageImportService.ts:169-213. On a parent cycle it returns true without finalizeImportable, leaving a stale entry in importableVisiting. Not reachable with valid (acyclic) input; low impact.
  • Asset-kind dedup precedencesrc/services/packageExportService.ts:115-132. Script paths are assigned last-write-wins while template/capture paths use if (!has), so a path used as both user-script and template is classified user-script. Likely intended; flagging for confirmation.
  • utility.getSelectedText returns undefined on error branchessrc/quickAddApi.ts:499-519 — while getSelection returns "". Minor API-shape inconsistency for user scripts.

Test coverage for each path now exists (#1245), so fixes can be verified by adjusting the corresponding assertion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions