← reports

#5834 · File opener registration rejects separator-containing extensions

Bug Priority: Medium Effort: Low plugins · GitHub issue · 2026-10-20

Trusted main: b0bb68655adcc6cd79e495d3484f4011a0640e2e

Verdict: REPRODUCED · Root-cause confidence: high

1. TL;DR

A plugin cannot register a file viewer for extensions containing an underscore or hyphen. Its setup fails before a file can be opened, even though the downstream file resolver can preserve and match these extension characters. The collector applies an alphanumeric-only check to each extension. A registration-to-resolution regression test fails at that exact check in two separate clean checkouts of the same trusted main commit.

2. Claims vs findings

ClaimFindingEvidence
Underscore-containing extensions cannot register.VerifiedThe synthetic design_board case throws from the real collector in both runs.
Hyphen-containing extensions encounter the same restriction.VerifiedThe synthetic workspace-file case throws at the same check.
The resolver itself preserves these extension characters.Verified by source inspectionIt slices after the final dot, lowercases the result, then uses exact membership matching. No separator restriction exists there.
The failed registration disables the plugin frontend.Supported by source; not exercised liveThe frontend catch block deactivates the committed generation and records failed status.
Specific KiCad viewers and the reported published SDK version behave identically.Not separately testedThis report tests trusted main and SDK 0.6.59, not external viewer code or older published binaries.

3. Environment

4. Minimal reproduction

The complete regression patch is embedded below. Save that block as registration-regression.patch; it adds two cases to the existing registration test. Raw artifacts are retained locally rather than published, in accordance with the reports repository's privacy policy.

  1. Prepare a new checkout of the recorded trusted commit:
git clone https://github.com/get-bb/bb.git bb-5834
cd bb-5834
git checkout --detach b0bb68655adcc6cd79e495d3484f4011a0640e2e
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build build:types --filter=@get-bb/plugin-sdk
git apply /path/to/registration-regression.patch
pnpm exec turbo run test --filter=@bb/app -- src/lib/plugin-app-definition.test.ts -t 'registers and resolves a file opener'

Expected: both cases collect a viewer and resolve an uppercase filename extension to that viewer. Actual: both fail while collecting the registration, before resolution.

Error: slots.fileOpener: extensions must be lowercase alphanumerics without the dot, got "design_board"
Error: slots.fileOpener: extensions must be lowercase alphanumerics without the dot, got "workspace-file"
Test Files  1 failed (1)
     Tests  2 failed | 54 skipped (56)

Added test body, using the existing file's imports and Component fixture (plus the resolver import included in the patch):

it.each(["design_board", "workspace-file"])(
  "registers and resolves a file opener for %s",
  (extension) => {
    const definition = definePluginApp((app) => {
      app.slots.fileOpener({
        id: "viewer",
        title: "Viewer",
        extensions: [extension],
        component: Component,
      });
    });
    const collected = collectPluginAppRegistrations(definition);
    const registrations = collected.fileOpeners.map((registration) => ({
      ...registration,
      pluginId: "extension-viewer",
      generation: 1,
    }));
    expect(collected.fileOpeners).toEqual([
      { id: "viewer", title: "Viewer", extensions: [extension], component: Component },
    ]);
    expect(resolveFileOpenerReplacement({
      registrations,
      path: `project/file.${extension.toUpperCase()}`,
    })).toEqual({ kind: "plugin", registration: registrations[0] });
  },
);

Complete regression patch

diff --git a/apps/app/src/lib/plugin-app-definition.test.ts b/apps/app/src/lib/plugin-app-definition.test.ts
index 1b8261324..fc131fbd4 100644
--- a/apps/app/src/lib/plugin-app-definition.test.ts
+++ b/apps/app/src/lib/plugin-app-definition.test.ts
@@ -10,6 +10,7 @@ import {
   definePluginApp,
   isPluginAppDefinition,
 } from "./plugin-app-definition";
+import { resolveFileOpenerReplacement } from "./plugin-slot-resolvers";
 
 function Component() {
   return null;
@@ -421,6 +422,41 @@ describe("collectPluginAppRegistrations — experimental_sidebarFooter", () => {
 });
 
 describe("collectPluginAppRegistrations", () => {
+  it.each(["design_board", "workspace-file"])(
+    "registers and resolves a file opener for %s",
+    (extension) => {
+      const definition = definePluginApp((app) => {
+        app.slots.fileOpener({
+          id: "viewer",
+          title: "Viewer",
+          extensions: [extension],
+          component: Component,
+        });
+      });
+      const collected = collectPluginAppRegistrations(definition);
+      const registrations = collected.fileOpeners.map((registration) => ({
+        ...registration,
+        pluginId: "extension-viewer",
+        generation: 1,
+      }));
+
+      expect(collected.fileOpeners).toEqual([
+        {
+          id: "viewer",
+          title: "Viewer",
+          extensions: [extension],
+          component: Component,
+        },
+      ]);
+      expect(
+        resolveFileOpenerReplacement({
+          registrations,
+          path: `project/file.${extension.toUpperCase()}`,
+        }),
+      ).toEqual({ kind: "plugin", registration: registrations[0] });
+    },
+  );
+
   it("produces the same complete registration set in the app and test runtimes", async () => {
     const run = () => {};
     const mount = () => {};

5. Root cause

The SDK collector validates extensions before adding the file opener:

if (typeof extension !== "string" || !/^[a-z0-9]+$/.test(extension)) {
  throw new Error(...);
}

That character class excludes both separators. In contrast, extension extraction returns the suffix unchanged apart from lowercase normalization. File-opener selection checks whether that suffix is in the registered extension list.

The exception propagates out of the complete plugin setup. The frontend failure handler then deactivates the committed generation and stores failed status. This explains why an overly strict file-extension check can remove more than the individual opener. No daemon or filesystem behavior is involved in the observed failure.

The alphanumeric-only check dates to commit 564090dfb1 according to blame; it is still present in the recorded main commit.

6. Proposed fix

Permit lowercase alphanumeric segments joined by an underscore or hyphen at the existing registration boundary. Keep dots, uppercase letters, whitespace, path separators, and empty segments invalid. Document the same grammar in the SDK declaration and Plugin Guide. Cover both registration and subsequent case-normalized file matching with the focused table, while retaining malformed-input tests. No change to the resolver, wire types, stored data, or dependencies is needed.

7. Related issues and PR status

No connected open PR or open PR matching issue number 5834 was found at investigation time. The repository-wide extension/underscore search returned only this issue. #2519 also concerns file openers but describes host-routing compatibility, not this registration restriction.

8. Verification

The same agent repeated the test in a second clean checkout of b0bb68655adcc6cd79e495d3484f4011a0640e2e. The checkout initially had an empty git status. It received only the regression patch, its own frozen install, and an SDK runtime/type build. The exact focused Turbo command shown above again returned exit 1: two intended failures at collector line 927, with 54 unrelated tests skipped. This is a repeated clean reproduction, not an independent review. The second run supported the first result; no verdict correction was needed.

First checkout:  2 failed | 54 skipped (56), duration 772ms, exit 1
Second checkout: 2 failed | 54 skipped (56), duration 888ms, exit 1
Both failures: collector line 927, alphanumeric-only extension validation.

9. Appendix

The initial whole-repository pnpm exec turbo run build hit a pre-existing cold-build ordering problem: the GitHub plugin tried to bundle the SDK host entry before its runtime output existed. The SDK runtime subsequently built successfully; an explicit SDK type build and whole-build retry passed (67 tasks). This does not affect the observed test exception. The read-only verification inventory also reported the pre-existing unmapped browser CLI family; that inventory failure is not evidence about this extension bug. No live frontend or rendering journey is claimed as passed.

Investigation commands additionally included git fetch origin main, git rev-parse origin/main, git blame -L 919,931 on the collector, repository issue/PR metadata reads, and inspection of the collector, resolver, existing registration tests, SDK declaration, and frontend error handler. Full raw output and test files are preserved in the local report backup, not published.

> AGENT GENERATED