Skip to content

fix: patch checksum validation logic#118

Merged
anuragxxd merged 1 commit into
devfrom
fix/checksum
May 27, 2025
Merged

fix: patch checksum validation logic#118
anuragxxd merged 1 commit into
devfrom
fix/checksum

Conversation

@anuragxxd
Copy link
Copy Markdown
Member

@anuragxxd anuragxxd commented May 27, 2025

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have not reduced the existing code coverage
  • I have added docstrings following the Python style guidelines of this project to all new modules, classes, methods and functions are documented with docstrings following; I have updated any previously existing docstrings, if applicable
  • I have updated any sections of the app's documentation that are affected by the proposed changes, if applicable

Summary by Sourcery

Bug Fixes:

  • Fix checksum validation logic for production tools by properly grouping checks for missing or empty checksum values.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 27, 2025

Reviewer's Guide

This PR fixes the checksum validation logic for production tools by adding proper parentheses around the missing/empty checksum checks in the process_files method to ensure the condition applies only when is_production is true.

Sequence Diagram: Corrected Checksum Validation in process_files

sequenceDiagram
    participant Caller
    participant RegisterObjectsEndpoint
    participant FileBeingProcessed

    Caller->>RegisterObjectsEndpoint: process_files()
    loop For each file (_file)
        RegisterObjectsEndpoint->>RegisterObjectsEndpoint: Check self.data['is_production']
        alt self.data['is_production'] is true
            RegisterObjectsEndpoint->>FileBeingProcessed: Access _file['file_wrapper'] to check checksum
            alt 'checksum' is missing or empty in _file['file_wrapper']
                RegisterObjectsEndpoint->>RegisterObjectsEndpoint: Log error: "Production tools must contain checksum..."
                RegisterObjectsEndpoint->>Caller: Raise BadRequest (due to checksum issue)
            else Checksum is valid for production tool's file
                RegisterObjectsEndpoint->>RegisterObjectsEndpoint: Continue processing _file
            end
        else is_production is false (checksum validation skipped)
            RegisterObjectsEndpoint->>RegisterObjectsEndpoint: Continue processing _file
        end
    end
Loading

Class Diagram: Update to RegisterObjectsEndpoint Class

classDiagram
  class RegisterObjectsEndpoint {
    +process_files(): void
  }
Loading

File-Level Changes

Change Details Files
Correct logical grouping in checksum validation condition
  • Wrapped the missing/empty checksum checks in parentheses
  • Adjusted line breaks for the condition to enhance readability
trs_filer/ga4gh/trs/endpoints/register_objects.py

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

@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.88%. Comparing base (1c8572c) to head (64bd2f4).
Report is 1 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #118   +/-   ##
=======================================
  Coverage   94.88%   94.88%           
=======================================
  Files          12       12           
  Lines         586      586           
=======================================
  Hits          556      556           
  Misses         30       30           

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown

@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 @anuragxxd - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Documentation: all looks good

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.

Comment thread trs_filer/ga4gh/trs/endpoints/register_objects.py
@anuragxxd anuragxxd requested a review from uniqueg May 27, 2025 09:18
@uniqueg uniqueg changed the title fix: ensure checksum validation for production tools in register_obje… fix: fix: clarify checksum validation precedence May 27, 2025
@uniqueg uniqueg changed the title fix: fix: clarify checksum validation precedence fix: patch checksum validation logic May 27, 2025
@anuragxxd anuragxxd merged commit bd68b57 into dev May 27, 2025
6 checks passed
@anuragxxd anuragxxd deleted the fix/checksum branch May 27, 2025 10:05
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