Skip to content

Adding additional logging to capture connection problems - #281

Open
jodeleeuw wants to merge 9 commits into
mainfrom
test
Open

jodeleeuw wants to merge 9 commits into
mainfrom
test

Conversation

@jodeleeuw

Copy link
Copy Markdown
Member

No description provided.

jodeleeuw and others added 8 commits September 22, 2026 08:30
Both deploy workflows set NEXT_PUBLIC_BASE_URL, but nothing read it, so
samples copied from datapipe-test.web.app fell through to the packages'
built-in pipe.jspsych.org and wrote to production. The API reference
printed the production origin too.

lib/base-url.js now reads it, with production as the fallback. The API
reference uses it, and on any non-production build every sample passes
the deployment explicitly (base_url for the extension, baseURL for
datapipe-client). Production samples are unchanged.

Fixes #246

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Point the test site's code samples at the test site
- Reject experiment IDs Firestore can't store (e.g. an unfilled
  "__DATAPIPE_STUDY1_ID__" placeholder) with the normal not-found
  response. Firestore throws on these instead of missing, so /api/data
  answered with a 500.
- Log the provider error when createexperiment returns a 502, so the
  failure is visible in Cloud Logging and not only in the browser.
- Check the HTTP status in OSF listFiles. An OSF error response crashed
  with "Cannot read properties of undefined (reading 'filter')", which
  hid OSF's real status and failed uploads permanently through the
  collision cache.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
getExperiment() returns null for a missing experiment and for an id
Firestore would reject outright, so every endpoint that looks an
experiment up by a client-supplied id keeps a single not-found branch
and none can reach the doc() call that throws. This replaces the guard
copied into six handlers and extends the fix to clear-errors and
ensure-derived-paths, which still returned 500s.

- api-queue-status checks its `download` queue-entry id the same way
  (404 instead of a 500 on "__x__" or "a/b").
- writeLog skips ids Firestore would reject, rather than every caller
  avoiding it on a comment that said it would throw (it never did).
- create-experiment logs the Error object and the uid on a 502.
- OSF listFiles errors carry OSF's own errors[0].detail, falling back
  to statusText.
- Emulator coverage now includes session start, finalize, clear-errors,
  ensure-derived-paths and queue-status (experimentID and download).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Return clear errors instead of crashes on three production failure paths
validateStaticToken collapsed every non-200 into "invalid", and the
connect endpoint turns that into "Invalid API token" without logging
anything. A real 401, a firewall 403, and an outage 5xx looked the same
after the fact, which left #278 undiagnosable. Log the server, status,
and a truncated, token-scrubbed body so the next failure says why.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ogging

Log why a Dataverse server rejected a token at connect
…logs

validateStaticToken read the whole non-200 body with response.text() from a
researcher-chosen server, so a hostile or slow-dripping installation could
exhaust dashboardapi's shared memory. It now reads at most 4KB for at most
5s, then drops the connection, and flattens the logged body to one line.

createExperimentHandler logged the raw provider Error, but a Dataverse
installation can echo the API key in its error text. The logged stack is
now scrubbed with the same redaction validateStaticToken uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cap Dataverse token-check body read; scrub tokens from create-experiment logs
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