Skip to content

fix: Update S3 prefix listing to work with ListObjectsV2 API #946

Merged
chrisj merged 2 commits intogoogle:masterfrom
dxenes1:fix-s3-autocomplete
Apr 8, 2026
Merged

fix: Update S3 prefix listing to work with ListObjectsV2 API #946
chrisj merged 2 commits intogoogle:masterfrom
dxenes1:fix-s3-autocomplete

Conversation

@dxenes1
Copy link
Copy Markdown
Contributor

@dxenes1 dxenes1 commented Apr 2, 2026

Got a fix here for the s3 autocomplete. If this has been fixed or addressed in another PR or issue, please disregard. Thanks for your review!

Summary of issue
I noticed for the past couple months that S3 URIs have not been completing in the source input box in Chrome/Safari/Firefox. Should be reproducible in any mainline Neuroglancer distribution. (Try s3://bossdb-open-data/)

Google cloud bucket URIs were autocompleting. I assumed it was an issue with the listing operation itself but the XML response looked correct to me (properly showing all prefixes delimited by a /), so I think I tracked the issue with the XML parser in the S3 listing script here.

What Changed

  • File changed: src/kvstore/s3/list.ts
  • Updated root element validation to use documentElement.localName instead of tagName.
  • Replaced XPath-based extraction with namespace-aware DOM traversal via getElementsByTagNameNS for:
    • CommonPrefixes > Prefix (directories)
    • Contents > Key (entries)

Technically we might not need Keys or individual objects.
Impact
S3-backed datasource URL autocomplete now surfaces prefixes/files as expected for namespace-qualified ListObjectsV2 XML responses.

Testing

  • Ran: npm test -- tests/kvstore/s3.spec.ts
    • Passed
  • Manually tested S3 and GCP URIs for autocomplete on Chrome/Firefox/Safari

This change was implemented with assistance from Codex (AI coding assistant). CLA has been signed.

@jbms
Copy link
Copy Markdown
Collaborator

jbms commented Apr 2, 2026

Can you add a test of the parsing to demonstrate the failure with the old code (which gets fixed with the new code)?

@dxenes1
Copy link
Copy Markdown
Contributor Author

dxenes1 commented Apr 3, 2026

Can you add a test of the parsing to demonstrate the failure with the old code (which gets fixed with the new code)?

Added as a browser test (passes with this branch, fails in master). Running the test as a spec tests passes in the original implementation because node's jsdom has a more permissive XML parsing. Chromium fails with its stricter XML parsing (needs an exact match on the namespace)

Tested via npm test -- --project browser tests/kvstore/s3.browser_test.ts.

Copy link
Copy Markdown
Contributor

@chrisj chrisj left a comment

Choose a reason for hiding this comment

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

Thanks @dxenes1! I have a few suggestions but they are really about the prior code so I'm good with merging this PR

namespaceURI,
"Prefix",
);
for (let j = 0; j < prefixNodes.length; ++j) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

these for loops would be a bit cleaner as for..of

);
for (let j = 0; j < prefixNodes.length; ++j) {
let name = prefixNodes.item(j)!.textContent;
if (name === null) continue;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think null is a possibility because these are Element not Node if we trust lib.dom.d.ts

Copy link
Copy Markdown
Contributor

@seankmartin seankmartin left a comment

Choose a reason for hiding this comment

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

thanks for the fix!

@chrisj chrisj merged commit 850f57b into google:master Apr 8, 2026
23 checks passed
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.

4 participants