Skip to content

Fix/make sure start date before end date#27611

Merged
eselkin merged 12 commits intomasterfrom
fix/make-sure-start-date-before-end-date
Apr 7, 2026
Merged

Fix/make sure start date before end date#27611
eselkin merged 12 commits intomasterfrom
fix/make-sure-start-date-before-end-date

Conversation

@eselkin
Copy link
Copy Markdown
Contributor

@eselkin eselkin commented Apr 6, 2026

Summary

  • This work is behind a feature toggle (flipper): YES but it is on for all users
  • Makes sure that Dates have a start_date before and end_date. Since date-times come from the devices (mobile or web), we can't just flip the start_date and end_date so we just prevent running the fetch if start_date is ahead of the current date.
  • The issue is a request will receive a 400 from SCDF with incorrect dates
  • UAE / Orion / Appointments

Related issue(s)

Testing done

  • New code is covered by unit tests

Screenshots

Note: Optional

What areas of the site does it impact?

(Describe what parts of the site are impacted andifcode touched other areas)

Acceptance criteria

  • I fixed|updated|added unit tests and integration tests for each feature (if applicable).
  • No error nor warning in the console.
  • Events are being sent to the appropriate logging solution
  • Documentation has been updated (link to documentation)
  • No sensitive information (i.e. PII/credentials/internal URLs/etc.) is captured in logging, hardcoded, or specs
  • Feature/bug has a monitor built into Datadog (if applicable)
  • If app impacted requires authentication, did you login to a local build and verify all authenticated routes work as expected
  • I added a screenshot of the developed feature

Requested Feedback

Check that in staging no 400 errors are received from SCDF in the logs:
https://vagov.ddog-gov.com/logs?saved-view-id=4635

@eselkin eselkin requested a review from JunTaoLuo April 7, 2026 16:30
JunTaoLuo
JunTaoLuo previously approved these changes Apr 7, 2026
Copy link
Copy Markdown
Contributor

@JunTaoLuo JunTaoLuo left a comment

Choose a reason for hiding this comment

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

LGTM!

@eselkin eselkin marked this pull request as ready for review April 7, 2026 17:51
@eselkin eselkin requested review from a team as code owners April 7, 2026 17:51
Copilot AI review requested due to automatic review settings April 7, 2026 17:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds guards to prevent Unified Health Data (SCDF) AVS metadata fetches when date ranges are invalid or when the appointment is in the future, reducing upstream 400s for VAOS appointment requests.

Changes:

  • Skip AVS metadata fetch for single OH appointments unless the appointment start is in the past.
  • Add start/end date range short-circuiting before calling UHD/SCDF.
  • Add unit/request specs covering invalid date ranges, equality edge case, Date-object inputs, and future-appointment behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
modules/vaos/app/services/vaos/v2/appointments_service.rb Avoid AVS fetch for future OH appointments; add date-range guard and expand error logging context.
modules/vaos/spec/requests/vaos/v2/appointments_spec.rb Add request spec ensuring AVS isn’t fetched/returned for future OH appointment even when requested.
lib/unified_health_data/service.rb Add date-order check before calling UHD client for AVS metadata.
spec/lib/unified_health_data/service_spec.rb Add unit specs for invalid date order, equality case, and Date object inputs.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
eselkin and others added 2 commits April 7, 2026 10:58
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@eselkin eselkin requested a review from JunTaoLuo April 7, 2026 17:59
@eselkin eselkin merged commit c79523b into master Apr 7, 2026
42 of 43 checks passed
@eselkin eselkin deleted the fix/make-sure-start-date-before-end-date branch April 7, 2026 18:11
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.

4 participants