Skip to content

huami fetch start: bad date isn't ok, so a 1970 round never stamps samples - #106

Merged
abdulsaheel merged 3 commits into
mainfrom
fix/huami-fetch-start-1970
Dec 5, 2026
Merged

abdulsaheel merged 3 commits into
mainfrom
fix/huami-fetch-start-1970

Conversation

@abdulsaheel

@abdulsaheel abdulsaheel commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

a fetch-start reply with a zeroed/garbage date gave roundStart 1970 with ok+hasData still true, so the whole round got stamped at epoch 0. ok is now false in that case and the edge caller already bails on !ok.

Summary by Sourcery

Prevent invalid Huami fetch-start dates from being accepted as usable rounds.

Bug Fixes:

  • Reject fetch-start replies with invalid or implausible dates so they cannot be treated as usable rounds or stamp samples at the 1970 placeholder.

Tests:

  • Add coverage confirming invalid dates and normalized dates such as February 31 produce unusable fetch-start results.

Summary by CodeRabbit

  • Bug Fixes
    • Start replies are now accepted only when the status is successful and the round-start year is between 2000 and 2100.
    • Invalid calendar dates, such as February 31, are rejected instead of being normalized. Rejected replies are marked unsuccessful, contain no data, and use 1970 as the fallback date.

@sourcery-ai

sourcery-ai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

API

Reject fetch-start replies with implausible or normalized dates so they cannot be accepted as usable rounds.

  • lib/src/huami2021_fetch.dart L76-78, L110-113

Tests

Verify invalid fetch-start dates produce the 1970 placeholder and are not considered valid or data-bearing rounds.

  • test/huami2021_fetch_test.dart L75-87

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

@coderabbitai

coderabbitai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The fetch parser now rejects implausible round-start dates and dates that normalize to a different month or day. Its success status requires status 0x01 and a round-start year from 2000 through 2100. Tests cover the fallback date and unsuccessful reply state.

Changes: Fetch date validation

Layer / File(s) Summary
Round-start validation
lib/src/huami2021_fetch.dart, test/huami2021_fetch_test.dart
The parser uses the 1970 placeholder when a date fails plausibility checks or normalizes to a different month or day. The reply is successful only when status is 0x01 and the round-start year is within 2000–2100. Tests verify invalid-date fallback and unsuccessful reply state.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: Minimal · up to 31afe

Fetch-start replies with invalid or impossible dates are now rejected rather than stamped at 1970. The change is small and tested, and no concrete merge-blocking risk is established.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states the main change: a fetch-start reply with an invalid date now yields ok=false, so a 1970 placeholder round never stamps samples. The raw summary and objectives confirm the change adds…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title states the main change: a fetch-start reply with an invalid date now yields ok=false, so a 1970 placeholder round never stamps samples. The raw summary and objectives confirm the change adds a status and year check, rejects normalized dates such as February 31, and adds tests for both. The title is specific and matches the changeset, though it is long at 74 characters.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: dbbb5b02-cf1d-48c0-8c65-4f70b20ac328
Commits

Reviewing files that changed from the base of the PR and between bbd2df0 and 31afe2c.

Files selected for processing: 2

  • lib/src/huami2021_fetch.dart
  • test/huami2021_fetch_test.dart

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 2 issues

Sourcery assessment

Approval pending. 2 findings to address first.

Blocking findings: lib/src/huami2021_fetch.dart:78, lib/src/huami2021_fetch.dart:78


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread lib/src/huami2021_fetch.dart Resolved
Comment thread lib/src/huami2021_fetch.dart Resolved
@abdulsaheel
abdulsaheel merged commit 71d3126 into main Dec 5, 2026
4 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.

1 participant