Skip to content

fix: ensure datastore extensions are loaded before auto-resolve in config resolution#1064

Merged
stack72 merged 1 commit intomainfrom
fix/datastore-json-stdout-leak
Apr 2, 2026
Merged

fix: ensure datastore extensions are loaded before auto-resolve in config resolution#1064
stack72 merged 1 commit intomainfrom
fix/datastore-json-stdout-leak

Conversation

@stack72
Copy link
Copy Markdown
Contributor

@stack72 stack72 commented Apr 2, 2026

Summary

  • resolveDatastoreConfig() calls resolveDatastoreType() which checks the datastore type registry. After PR fix: lazy extension loading — only load registries when accessed #1050's lazy loading change, the registry is empty at this point because ensureLoaded() hasn't been called yet.
  • This causes the auto-resolver to fire unnecessarily, writing progress JSON ({"event":"auto_resolve","status":"searching","type":"@swamp/s3-datastore"}) to stdout — corrupting --json output for any command that uses an extension-based datastore (S3, GCS).
  • Adds ensureLoaded() calls before auto-resolve checks in all three code paths within resolveDatastoreConfig() and parseDatastoreEnvVar().

The rogue JSON was 74 chars for S3 (position 75) and 75 chars for GCS (position 76), matching the 1-char difference between @swamp/s3-datastore and @swamp/gcs-datastore.

Test Plan

🤖 Generated with Claude Code

…nfig resolution

resolveDatastoreConfig() calls resolveDatastoreType() which checks the
datastore type registry. After PR #1050's lazy loading change, the registry
is empty at this point because ensureLoaded() hasn't been called yet. This
causes the auto-resolver to fire unnecessarily, writing progress JSON
({"event":"auto_resolve","status":"searching","type":"@swamp/..."}) to
stdout — corrupting --json output for any command that uses an
extension-based datastore (S3, GCS).

Add ensureLoaded() calls before auto-resolve checks in all three code paths
within resolveDatastoreConfig() and parseDatastoreEnvVar(), so the registry
is populated from disk before the auto-resolver is consulted.

Fixes datastore UAT failures: status_test.ts:14, sync_test.ts:19,
sync_test.ts:96 on both S3 and GCS backends.
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

Clean, well-scoped bug fix. The root cause analysis is solid — after PR #1050's lazy loading change, datastoreTypeRegistry is empty when resolveDatastoreConfig() / parseDatastoreEnvVar() check it, causing the auto-resolver to fire and leak progress JSON to stdout.

Blocking Issues

None.

Suggestions

  1. Pre-existing import boundary violation (not introduced by this PR): Line 44 imports maybeAutoUpdateDatastoreExtension from ../libswamp/extensions/datastore_auto_update.ts instead of ../libswamp/mod.ts. Per CLAUDE.md, CLI code should import from src/libswamp/mod.ts. Worth fixing in a follow-up since the symbol is already re-exported from mod.ts.
  2. The comment block at lines 422-425 referencing "PR #1050" is useful context now but will become noise over time. A shorter comment like // Ensure lazy-loaded extensions are populated before registry lookup would age better. The detailed explanation fits well in the commit message (where it already lives).

LGTM — the fix correctly ensures the lazy-loaded registry is populated before each auto-resolve check point, and the existing test file covers the public API surface.

@stack72 stack72 merged commit 3685cc3 into main Apr 2, 2026
10 checks passed
@stack72 stack72 deleted the fix/datastore-json-stdout-leak branch April 2, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant