Skip to content

Fix Canvas Assignment Due Date Syncing#439

Open
cycomachead wants to merge 7 commits into
mainfrom
cycomachead/130-consider-the-code-for-updating-posting-an-assignment-override-to-canvas-audit-for-any-bugs-know-t/1
Open

Fix Canvas Assignment Due Date Syncing#439
cycomachead wants to merge 7 commits into
mainfrom
cycomachead/130-consider-the-code-for-updating-posting-an-assignment-override-to-canvas-audit-for-any-bugs-know-t/1

Conversation

@cycomachead

Copy link
Copy Markdown
Contributor

General Info

Changes

Audited and fixed 7 bugs in the Canvas assignment override update/post flow, addressing correctness issues around shared overrides, pagination, base due dates, and error handling.

Critical fixes:

  1. Shared overrides were being destroyed — the old flow deleted a student's entire override before re-creating one, wiping extensions for all other students in a shared group (e.g. "1 day extension"). Now: single-student overrides are updated in place; shared overrides have only the one student removed, preserving the title and dates for remaining students.

  2. update_assignment_override silently no-oped — params weren't nested under assignment_override as Canvas requires. Un-nested params are silently ignored by Canvas, meaning override updates (including renames) never applied. Override renames now go through correctly.

  3. Override lookups only read page 1 — Canvas paginates overrides (default 10/page), so with many overrides a student's existing override was never found, leading to duplicate create attempts and 400 errors. get_assignment_overrides now requests 100 items/page and a new get_all_assignment_overrides depaginates fully.

Base due date fix (>25 overrides):

  1. Incorrect base due datesget_all_assignments relied on all_dates, which Canvas omits when an assignment has more than 25 dates. The top-level due_at can then reflect an override's date. A new get_base_dates method uses the date_details endpoint (whose top-level dates are always the base/"Everyone" dates) and is called whenever all_dates is missing and has_overrides is true. The controller now uses this for initial_due_date as well.

Other fixes:

  1. Failed Canvas requests recorded as success — non-2xx create/update responses were wrapped in an Override with a nil id and the request was marked approved. provision_extension now raises CanvasAPIError on failure.
  2. Auth token leaked into paginated URLsdepaginate_response was passing headers: auth_header as Faraday query params, appending Authorization=Bearer … to follow-up page URLs. The connection's default headers already carry auth.
  3. Smaller fixesremove_student_from_override no longer mutates the caller's array; updates no longer reset unlock_at to "now"; override_has_errors? renamed to override_taken_error? with correct semantics; Lmss::Canvas::Assignment no longer falls back to a potentially override-tainted top-level date when base date info is present; Lmss::Canvas::Override exposes the full override fields needed by the controller.

Testing

  • Updated existing specs to reflect the corrected behavior (param nesting, no delete_assignment_override calls, correct unlock_at preservation).
  • Added new specs for: pagination of override lookups (override found on page 2), override rename on update, shared override preservation when a student is removed, lookup/create race condition recovery ("taken" recovery), get_base_dates (success/failure/bad JSON), date_details fallback in get_all_assignments, failure-status raising, and non-mutation of student_ids.
  • Full suite: 423 examples, 0 failures, rubocop clean.

Documentation

No documentation changes required.

Checklist

  • Name of branch corresponds to story

Superconductor Ticket Implementation | App Preview | Guided Review

cycomachead and others added 2 commits June 10, 2026 15:54
- Fix shared overrides being destroyed by removing students from groups
  instead of deleting the entire override.
- Fix update_assignment_override no-oping by nesting params correctly.
- Fix override lookups failing when > 25 overrides exist by implementing
  depagination and requesting 100 items per page.
- Fix incorrect base due dates by explicitly querying the date_details
  endpoint when Canvas omits all_dates.
- Ensure override renames are applied during updates.
- Prevent auth token leakage into paginated URLs.
- Improve error handling by raising CanvasAPIError for failed requests.

Co-authored-by: Claude Code <noreply@anthropic.com>
Implement logic to title and group assignment overrides by "N day(s) extension" instead of individual student IDs. This reduces the total override count to mitigate Canvas API limitations where date reporting becomes unreliable after 25 overrides.

- Add `get_base_dates` lookup to ensure accurate day calculation.
- Update `provision_extension` to merge students into existing matching groups.
- Handle student removal from shared overrides when extension lengths change.
- Ensure timezone-tolerant date matching for group identification.

Co-authored-by: Claude Code <noreply@anthropic.com>
@cycomachead cycomachead changed the title Consider the code for updating / posting an assignment override to Canvas * Audit for any bugs * Know that the Canvas API returns the wrong due da... Fix Canvas Assignment Due Date Syncin Jun 21, 2026
@cycomachead cycomachead changed the title Fix Canvas Assignment Due Date Syncin Fix Canvas Assignment Due Date Syncing Jun 21, 2026
cycomachead and others added 5 commits June 22, 2026 17:51
…der-the-code-for-updating-posting-an-assignment-override-to-canvas-audit-for-any-bugs-know-t/1
…ng-posting-an-assignment-override-to-canvas-audit-for-any-bugs-know-t/1

* main:
  fixup spec and includes call
  Add API parameters to Canvas Calls
  Add Min Hours Before Auto Approval
  Cleanup the courses import table to show semesters
  fix: derive course semester from dates when term name is blank
  Bump the bundler group across 1 directory with 5 updates
  Bump the npm_and_yarn group across 1 directory with 3 updates
  Bump dompurify in the npm_and_yarn group across 1 directory
  refactor: implement course staff permission check for enrollment sync
  feat: update Enrollments page UI and sync permissions
  Bump the bundler group across 1 directory with 2 updates
  Add Nia Robinson to the Contributors List
  Bump strong_migrations from 2.7.0 to 2.8.0
  Bump jbuilder from 2.14.1 to 2.15.1
  Bump rubocop from 1.86.1 to 1.86.2
  Bump hypershield from 0.6.0 to 0.6.1
Reconcile how we read the assignment base ("Everyone") date now that
override_assignment_dates=false reliably returns it at the top level for
any number of overrides.

- Drop the /date_details code path (get_assignment_date_details and the
  date_details-based get_base_dates): date_details has no base date field
  and its top-level dates duplicate override_assignment_dates=false.
- get_base_dates now reads the single-assignment endpoint top-level dates.
- Fix get_assignment params (drop the bogus all_dates=true) and drop the
  unused, heavy include[]=overrides from the bulk assignment list.
- Harden all_dates truncation handling: Canvas always returns all_dates as
  an array and signals truncation (>=25 dates, ALL_DATES_LIMIT) via
  all_dates_count. Only read the base entry when all_dates_count is absent
  and all_dates is non-empty; otherwise fall back to the top-level base
  date. Fixes the empty-array truthiness bug.
- Add docs/Canvas_Dates_API.md with cited internal developer notes and
  link it from developers.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
With override_assignment_dates=false, Canvas returns the base ("Everyone")
due_at/unlock_at/lock_at at the top level of the assignment hash for any
number of overrides (verified against the pinned serializer). That makes
include[]=all_dates and its base_date plumbing pure redundancy, so remove it:

- get_assignments no longer requests include[]=all_dates.
- get_all_assignments builds POROs straight from the top-level fields.
- Lmss::Canvas::Assignment#extract_date_field reads the top-level field only
  (drop the base_date branch).
- Drop base_date derivation from the spec helper and the base_date job spec
  test (replaced with a top-level-dates test).

Also document the all_dates-vs-overrides distinction (overrides carries the
full, untruncated override records but never the base date; all_dates carries
a truncated date summary that does) and update the doc to reflect that we rely
solely on the top-level dates.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…e-for-updating-posting-an-assignment-override-to-canvas-audit-for-any-bugs-know-t/1' into cycomachead/130-consider-the-code-for-updating-posting-an-assignment-override-to-canvas-audit-for-any-bugs-know-t/1
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