Skip to content

Replace Bad Instance of databaseTiny.find()#474

Merged
thehabes merged 2 commits intodevelopmentfrom
471-odd-databaseTiny-find
Mar 12, 2026
Merged

Replace Bad Instance of databaseTiny.find()#474
thehabes merged 2 commits intodevelopmentfrom
471-odd-databaseTiny-find

Conversation

@thehabes
Copy link
Copy Markdown
Member

@thehabes thehabes commented Mar 12, 2026

Closes #471

Summary

  • Fix databaseTiny.find({_id}) in updateLayerAndProject() — replaced with fetch(page.id) pattern matching Page.js:183-205. The old call had two compounding bugs:
    1. find({_id}) fails collection resolution — determineDataType() cannot identify a type from {_id} alone, so resolveCollection() returns null and the driver throws.
    2. find() returns an array — even if resolution worked, the code treated the result as a single document, setting .partOf on an array.
  • Correct smoke test — changed expected status from 400 to 401 for unauthenticated /my/profile requests.

Changes

File Change
utilities/shared.js:87-112 Replace databaseTiny.find() with fetch(page.id) + error handling + response body validation
__tests__/smoke.test.js:60-63 Fix expected status code 400 → 401

Why fetch(page.id) instead of fixing the find() call

The page IDs in this code path are already full RERUM URLs (filtered by .startsWith(process.env.RERUMIDPREFIX) on line 85). Fetching by URL is the established pattern throughout the codebase (Page.js:183, Page.js:82) and avoids both the collection resolution issue and the array-vs-document issue entirely. No new dependencies — fetch is native in Node 18+.

This comment was marked as outdated.

@thehabes thehabes marked this pull request as ready for review March 12, 2026 20:35
@thehabes thehabes requested a review from cubap as a code owner March 12, 2026 20:35
@thehabes thehabes merged commit 3e04771 into development Mar 12, 2026
3 checks passed
@thehabes thehabes deleted the 471-odd-databaseTiny-find branch March 12, 2026 20:41
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.

2 participants