Skip to content

Fix indexStorePath/indexDatabasePath being transposed in BSP response - #1576

Open
AnupamKumar-1 wants to merge 1 commit into
swiftlang:mainfrom
AnupamKumar-1:fix-index-store-database-path-swap
Open

Fix indexStorePath/indexDatabasePath being transposed in BSP response#1576
AnupamKumar-1 wants to merge 1 commit into
swiftlang:mainfrom
AnupamKumar-1:fix-index-store-database-path-swap

Conversation

@AnupamKumar-1

Copy link
Copy Markdown

Fixes swiftlang/swift-package-manager#10350

Note: the linked issue was filed against swift-package-manager, but the root cause is in swift-build's BSP server implementation, so the fix lives here.

Summary

indexStorePath and indexDatabasePath in SWBBuildServer's BSP build/initialize response were transposed:

  • indexStorePath derived a sibling directory (dirname(indexDataStoreFolderPath)/index-store) that nothing ever writes to.
  • indexDatabasePath returned indexDataStoreFolderPath directly — i.e. the real index store location — mislabeled as a database path.

Any BSP client that trusts indexStorePath (e.g. SourceKit-LSP with swiftPM.buildSystem: "swiftbuild") opens a valid-but-empty store and silently returns no results for cross-file queries.

Fix

  • indexStorePath now returns arenaInfo.indexDataStoreFolderPath directly — the actual directory the build writes index data into.
  • indexDatabasePath now derives a sibling directory (DataStoreDB, following the naming convention already used for adjacent Index.noindex paths in SWBTestSupport/Misc.swift: DataStore, PrecompiledHeaders, Build) so a client can safely create its own IndexStoreDB without colliding with the raw store.

Verification

Reproduced and confirmed with a real package, using the swiftbuild backend end-to-end:

  1. Captured the real -index-store-path from a verbose swift build --build-system swiftbuild -v compile invocation.
  2. Queried swift package experimental-build-server --build-system swiftbuild directly over stdio with a raw build/initialize request and confirmed the advertised paths didn't match the real one (before fix).
  3. After the fix, rebuilt and re-queried: indexStorePath now matches the real store path, and .build/out/v5/{units,records} are confirmed present exactly where indexStorePath claims.
  4. indexDatabasePath now points at a distinct, non-colliding sibling path.

Testing

Added indexStoreAndDatabasePathsAreNotTransposed in BuildServerTests.swift, which constructs a build request with an explicit SWBArenaInfo and asserts indexStorePath matches the real derived-data path while indexDatabasePath remains distinct from it. Verified the test fails without the fix and passes with it.

indexStorePath pointed at a directory nothing writes to, while
indexDatabasePath returned the real index store location. BSP
clients like SourceKit-LSP opened a valid-but-empty store and
silently returned no results.

Fixes swiftlang/swift-package-manager#10350
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.

experimental-build-server reports an indexStorePath that doesn't match where swift build writes the index store

1 participant