Bug in dat/list/by_alloc route

Open Beginner friendly
#819 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
62/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
backend, database

Research direction

Start at the dat/list/by_alloc route and inspect the else branch around the g_db._query call and the following result loop. Verify how the route behaves when that branch runs, then ensure the query result is an array and confirm the loop processes the route output without errors.

Written by the indexing model from the issue text.

Description

Type: Bug

At the bottom of the route, if the else branch is triggered than an array is not being output this leads to problems in the for loop at the very bottom.

        else{
            qry += " return { id: v._id, title: v.title, alias: v.alias, owner: v.owner, creator: v.creator, size: v.size, md_err: v.md_err, external: v.external, locked: v.locked }";
            result = g_db._query( qry, { repo: req.queryParams.repo, uid: owner_id });
        }

        for ( var i in result ){
            doc = result[i];
            if ( doc.id ){
                doc.notes = g_lib.getNoteMask( client, doc );
            }
        }

The solution is to ensure the result is first converted to an array.

result = g_db._query( qry, { repo: req.queryParams.repo, uid: owner_id }).to_array();
Dominant language
JavaScript
Stars
27
Forks
14
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ORNL/DataFed

All issues in ORNL/DataFed

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.