Skip to content

Fix for download/dataget operations#1889

Open
nedvedba wants to merge 1 commit intostagingfrom
fix-dataget-download-issue
Open

Fix for download/dataget operations#1889
nedvedba wants to merge 1 commit intostagingfrom
fix-dataget-download-issue

Conversation

@nedvedba
Copy link
Collaborator

@nedvedba nedvedba commented Mar 11, 2026

Description

How Has This Been Tested?

Artifacts (if appropriate):

Tasks

  • - A description of the PR has been provided, and a diagram included if it is a new feature.
  • - Formatter has been run
  • - CHANGELOG comment has been added
  • - Labels have been assigned to the pr
  • - A reviwer has been added
  • - A user has been assigned to work on the pr
  • - If new feature a unit test has been added

Summary by Sourcery

Handle registration and generic replies more robustly by treating only non-zero, non-UNSPECIFIED error codes as errors and fix task presence detection in data download command.

Bug Fixes:

  • Avoid incorrectly treating empty or UNSPECIFIED error codes as failures in user registration and generic reply handling.
  • Ensure dataGet waits on a task only when the task field is actually present in the reply.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Mar 11, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts error-handling conditions for registration and generic reply handling in the web service so that only explicit, non-zero, non-"UNSPECIFIED" error codes are treated as failures, and fixes the Python client dataGet logic to check for presence of a task field using protobuf’s HasField before waiting on task progress.

Flow diagram for updated dataGet task wait logic in CommandLib

flowchart TD
    Start[Call_dataGet]
    BuildRequest[Build dataGet
request message]
    SendRecv[Send request via mapi
and receive reply list]
    CheckTask{reply_index_0
HasField task
AND wait is True}
    BuildTaskView[Build sdms
TaskViewRequest
with task_id
from reply_index_0.task.id]
    WaitLoop[Poll task status
until completion
or timeout]
    ReturnResult[Return final
result to caller]

    Start --> BuildRequest --> SendRecv --> CheckTask
    CheckTask -- Yes --> BuildTaskView --> WaitLoop --> ReturnResult
    CheckTask -- No --> ReturnResult
Loading

File-Level Changes

Change Details Files
Tighten error detection for user registration and generic reply handling in the Node.js web service.
  • Update the registration handler to treat a reply as an error only when errCode is defined, non-zero, and not equal to "UNSPECIFIED"
  • Update the generic sendMessage reply handler to apply the same explicit errCode checks before logging and returning an error response
web/datafed-ws.js
Fix task presence check in Python dataGet so it works reliably with protobuf replies.
  • Replace direct truthiness check on reply[0].task with reply[0].HasField("task") before entering task-wait loop when wait is enabled
python/datafed_pkg/datafed/CommandLib.py

Possibly linked issues

  • #[Bug] Dataget and download operations not working: PR changes reply error handling and task field checks, directly targeting failed dataget/download operations described in issue.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The error-code checks for registration and generic replies now use the same multi-clause condition; consider extracting this into a shared helper (e.g., isErrorCode(errCode)) to avoid duplication and keep the semantics consistent if they change later.
  • The errCode comparisons mix numeric (0) and string ("UNSPECIFIED") values; it might be more robust to normalize errCode to a single type or use a small mapping/enum to avoid subtle bugs if the backend changes its representation.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The error-code checks for registration and generic replies now use the same multi-clause condition; consider extracting this into a shared helper (e.g., `isErrorCode(errCode)`) to avoid duplication and keep the semantics consistent if they change later.
- The `errCode` comparisons mix numeric (`0`) and string (`"UNSPECIFIED"`) values; it might be more robust to normalize `errCode` to a single type or use a small mapping/enum to avoid subtle bugs if the backend changes its representation.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@nedvedba nedvedba changed the title hypothetical fixes for download/dataget Fix for download/dataget operations Mar 11, 2026
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