Skip to content

Report a login failure from the CLI as a readable error - #4053

Merged
nellh merged 1 commit into
OpenNeuroOrg:masterfrom
adityasingh2400:fix-3523-login-error-message
Aug 12, 2026
Merged

Report a login failure from the CLI as a readable error#4053
nellh merged 1 commit into
OpenNeuroOrg:masterfrom
adityasingh2400:fix-3523-login-error-message

Conversation

@adityasingh2400

Copy link
Copy Markdown
Contributor

Fixes #3523.

Creating a dataset without valid credentials produced two unhelpful outcomes, both visible in the tracebacks on the issue.

First, createDataset stringified the whole GraphQL errors array, so the one line that matters, "You must be logged in to create a dataset.", was buried in a server side stacktrace.

Second, a response carrying data.createDataset: null with no top level errors made createDataset resolve to undefined despite its Promise<string> type. That only failed much later as TypeError: Path must be a string, received "undefined" from the join(repoDir, datasetId) in upload.ts, which points the user at a path problem rather than at their credentials.

Only the GraphQL messages are kept now. An authentication failure raises LoginError naming the command that fixes it, and a response with no accession number is rejected where it happens instead of turning into a path error later. getLatestSnapshotVersion shares the same handling. The upload command prints that message and stops rather than throwing an uncaught error.

Reverting graphq.ts and upload.ts gives 1 passed and 4 failed: the no accession number case resolved undefined without throwing, the missing credentials case gave a ResponseError instead of a LoginError, and both message filtering cases returned the raw JSON array. After, the full CLI suite is green at 41 passed across 12 steps, with deno fmt and deno lint clean.

One note for anyone running this locally. cli/deno.json has "minimumDependencyAge": {"exclude": [...]}, which deno 2.6.10 rejects with Unsupported "minimumDependencyAge" object. Caused by: missing field 'age'. I dropped the key locally to run the tests and restored it before committing, so this branch does not touch it. CI pins deno-version: v2.x, so this may start biting soon.

Disclosure: this change was prepared with AI assistance. I have reviewed and tested it.

Creating a dataset without valid credentials produced two unhelpful
outcomes. The server error array was stringified whole, so the one line
that matters was buried in a server side stacktrace, and a response
carrying a null createDataset field made createDataset resolve to
undefined, which only failed later as "Path must be a string, received
undefined" from the path join in the upload command.

Keep only the GraphQL messages, raise a LoginError naming the command
that fixes it when the failure is an authentication one, and reject a
response that carries no accession number. The upload command now prints
that message and stops instead of throwing an uncaught error.

Fixes OpenNeuroOrg#3523
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.87500% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.04%. Comparing base (2ac78fc) to head (2783e26).
⚠️ Report is 22 commits behind head on master.

Files with missing lines Patch % Lines
cli/src/graphq.ts 78.57% 4 Missing and 2 partials ⚠️
cli/src/commands/upload.ts 25.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4053      +/-   ##
==========================================
+ Coverage   48.89%   49.04%   +0.15%     
==========================================
  Files         686      686              
  Lines       38069    38093      +24     
  Branches     1894     1906      +12     
==========================================
+ Hits        18615    18684      +69     
+ Misses      19293    19242      -51     
- Partials      161      167       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nellh nellh left a comment

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.

Thanks for your contribution.

@nellh
nellh merged commit 59568d0 into OpenNeuroOrg:master Aug 12, 2026
17 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.

Unhelpful error message for uploads when not logged in

2 participants