Repository navigation
feat(api): report MDBList search and the schedule time zone in collection capabilities - #1896
Conversation
…tion capabilities The Synced list editor needs to know, before it searches, whether MDBList search will return anything, and it labels cron times with the server's zone. Neither was discoverable: search silently answered configured=false and no endpoint reported the zone cron schedules run in. Both collection capability documents now report mdblist_search, from the same MDBList client the search route uses, and schedule_time_zone: the answering node's current utc_offset and abbreviation, plus the IANA name when TZ names one. Each node evaluates cron in its own local zone, so the value describes only the node that answered. Both fields are response-only on /api/v2; /api/v1 is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Personal collections computed their next sync from a UTC timestamp, and cron evaluates in the location of the time it is given, so after the first run a daily 04:30 schedule moved to 04:30 UTC. Admin schedules and the schedule_time_zone capability use local time. ComputeNextSyncAtFrom now evaluates the expression in time.Local for every caller. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The name came from re-reading TZ with time.LoadLocation, which also consults ZONEINFO, so it could name a zone that time.Local (and so the reported offset) never loaded. Read the name from time.Local instead. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 65bed2c546
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return nil | ||
| } | ||
| next := sched.Next(after) | ||
| next := sched.Next(after.In(time.Local)).In(after.Location()) |
There was a problem hiding this comment.
Preserve the 24-hour floor across DST
When time.Local observes daylight saving time, evaluating the personal daily schedule on the local wall clock makes consecutive runs around the spring transition roughly 23 hours apart (and jitter can shorten that further). This violates the explicit MinSyncIntervalHours = 24 invariant in internal/usercollections/types.go and the quota-bound schedule contract in internal/usercollections/validate.go; keep personal schedules on a fixed/UTC basis or otherwise enforce the minimum interval while applying local-time evaluation where that floor is not required.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing the schedule evaluation. MinSyncIntervalHours bounds the cadence, not the gap between two runs. The fixed schedule set (daily, weekly, monthly at 04:30) allows at most one run per calendar day. Nothing enforces a strict 24-hour gap per run, and nothing ever did: the 0–15 minute jitter alone puts two UTC daily runs as little as about 23h45m apart. The constant is only used to push next_sync_at back after a failed sync.
On local time, the spring change makes one gap a year 23 hours and the autumn change makes one 25 hours. The number of runs per year stays the same, so provider quota does not change. Admin schedules and the first personal run already ran on local time before this PR. This PR moves later personal runs to the zone the capability document reports. Keeping personal schedules on UTC would make schedule_time_zone wrong for them.
Enforcing a strict 24-hour floor after each run would push a daily list to every other day once sync time and jitter are added. The comment in internal/usercollections/validate.go still said "04:30 UTC" and promised a 24-hour gap. 65e58fc corrects it to describe the real guarantee.
|
No recorded Collections case needs re-validation or is unblocked by this diff. The PR adds fields to the existing Please replace the PR body's line with: Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
…es' into feat/api-collection-capabilities-sync # Conflicts: # contracts/api/v2/fixtures/get_collection_capabilities_ok.json # contracts/api/v2/fixtures/get_system_info_ok.json # contracts/api/v2/fixtures/index.json # contracts/api/v2/openapi.json # internal/apiv2/fixtures_test.go # internal/apiv2/personal_collections.go # internal/apiv2/personal_collections_test.go # web/src/api/v2/schema.ts
… clock The comment still said personal schedules fire at 04:30 UTC and that the fixed set guarantees a 24-hour gap. Since this branch evaluates them on the node's local clock, describe the real guarantee: at most one run a day, with 23- or 25-hour gaps across a daylight saving change. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Changed the PR body to |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 65e58fc088
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if reg.deps.ScheduleZone != nil { | ||
| return reg.deps.ScheduleZone() | ||
| } | ||
| return scheduleTimeZoneAt(time.Now(), ianaZoneName(time.Local.String())) |
There was a problem hiding this comment.
Handle per-expression cron time zones
When an administrator supplies a schedule such as CRON_TZ=UTC 30 4 * * *, catalog.ParseCronExpression accepts the robfig/cron zone prefix and the resulting schedule runs in UTC, but this capability always reports time.Local. The admin API accepts arbitrary sync_schedule strings through that parser, so clients can be told the wrong zone for valid stored schedules; either reject zone-prefixed expressions or represent the effective per-schedule zone instead of unconditionally advertising the node zone.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5359bd3: ParseCronExpression now rejects TZ= and CRON_TZ= prefixes, so admin and library collection writes answer 400 and every schedule runs in the zone schedule_time_zone reports.
…es' into feat/api-collection-capabilities-sync Brings in personal login sharing (#1875), the scrobble lock fix (#1887), and the phase-1 collection PRs. The personal capability test now expects both login_sharing and this branch's mdblist_search and schedule_time_zone. The OpenAPI document, fixtures, and web types are regenerated, with the admin collection capability fixture still appended last. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 903eb6fc90
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if os.Getenv("TZ") == "" && zone.Name != nil { | ||
| t.Errorf("%s: name %q reported without a TZ setting", read.path, *zone.Name) | ||
| } |
There was a problem hiding this comment.
Distinguish unset TZ from an explicitly empty value
When tests run with TZ= explicitly set, Go uses UTC and scheduleTimeZone() correctly returns name: "UTC", but os.Getenv("TZ") is also empty and this assertion requires the name to be omitted. This makes the package test fail in a valid UTC configuration; use os.LookupEnv to distinguish an unset variable from an explicitly empty one, or derive the expectation from time.Local.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5359bd3: the test now uses os.LookupEnv and only requires an omitted name when TZ is unset. It passes with TZ unset, TZ=, and TZ=America/Chicago.
…ities-sync Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fc9e3b0fa1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| func ianaZoneName(name string) string { | ||
| if name == "" || name == "Local" || strings.HasPrefix(name, "/") { | ||
| return "" | ||
| } | ||
| return name |
There was a problem hiding this comment.
Do not expose POSIX TZ values as IANA names
When the node uses a valid POSIX TZ value such as UTC0 or EST5EDT, time.Local.String() returns that value and this helper passes it through as schedule_time_zone.name. The API documents name as an IANA zone name, so clients that feed it to IANA-based time-zone APIs will reject or misinterpret the value; only return names known to be IANA identifiers (or omit the field for non-IANA TZ forms).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this. Go never names time.Local after a POSIX TZ rule: it only keeps a TZ value that loads as a tzdata zone file, and falls back to UTC otherwise. With Go 1.26, TZ=UTC0 and TZ=EST5EDT,M3.2.0,M11.1.0 both give time.Local.String() == "UTC", so name is UTC. EST5EDT and CST6CDT load because they are IANA tzdb identifiers (backward-compatible links in tzdata), and IANA-based APIs accept them.
schedule_time_zone reports the node's zone, but ParseCronExpression accepted robfig's TZ=/CRON_TZ= prefixes, so a stored schedule could run in a zone the capability does not report. Writes now reject those prefixes with 400. The capability test treated an explicitly empty TZ as unset; Go loads UTC for TZ= and reports the name, so the test now checks whether TZ is set. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5359bd3566
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| sched, err := cronParser.Parse(schedule) | ||
| if err != nil { | ||
| return nil | ||
| } | ||
| next := sched.Next(after) | ||
| next := sched.Next(after.In(time.Local)).In(after.Location()) |
There was a problem hiding this comment.
Reject time-zone prefixes when computing persisted schedules
Although ParseCronExpression now rejects new TZ=/CRON_TZ= inputs, this path parses the raw persisted expression directly, and robfig/cron still honors those prefixes. Any schedule saved before this validation change (or otherwise written directly) will therefore continue running in its embedded zone while schedule_time_zone advertises the node's local zone, so the documented single-zone behavior is not actually enforced; reject the prefixes here as well or normalize existing values before scheduling.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 3c52ab3: ComputeNextSyncAtFrom now sets the parsed schedule's location to time.Local, so a schedule stored with a TZ= or CRON_TZ= prefix before writes rejected them runs on the node's local clock, the zone schedule_time_zone reports.
ParseCronExpression rejects TZ=/CRON_TZ= on write, but a schedule stored before that still ran in its embedded zone while schedule_time_zone reported the node's zone. ComputeNextSyncAtFrom now evaluates every parsed schedule in time.Local. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3c52ab35c4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return name | ||
| } | ||
|
|
||
| // mdblistSearch reports whether the MDBList search the collection editors use |
There was a problem hiding this comment.
Omit non-IANA TZ values from the reported name
When the node uses a valid POSIX TZ value such as UTC0 or EST5EDT, time.Local.String() returns that value and ianaZoneName passes it through as schedule_time_zone.name. The API documents name as an IANA zone name, so clients that feed it into IANA-based time-zone APIs can reject or misinterpret the value; only return names known to be IANA identifiers, or omit the field for POSIX forms.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this; same finding as the earlier thread on this line. Go only names time.Local after a TZ value that loads as a tzdata zone file. TZ=UTC0 fails to load, so Go falls back to UTC and name is UTC (checked with Go 1.26). EST5EDT loads because it is an IANA tzdb identifier, a backward-compatible link in tzdata, so IANA-based APIs accept it.
Silo-Server#1896 made writes reject TZ= and CRON_TZ= cron prefixes with 400 and made stored prefixed schedules run on the node's local clock. Both changed existing behavior, including on the frozen /api/v1, for collections an admin had already given a zone. A prefixed schedule runs in the zone it names again, and the capability's schedule_time_zone describes schedules without a prefix. The fix that runs unprefixed schedules on the local clock whatever zone the reference time is in stays. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Problem
Related issue: #192
Validation tasks: none
The Synced list step in the collection editors needs two facts it can't get from the capability documents today. It has to know whether MDBList search can return any lists, and which time zone a cron sync schedule runs in, so it can label the time. Without them a client has to call MDBList search to find out it isn't configured, and it shows schedule times with no zone.
Both collection capability documents now report
mdblist_searchandschedule_time_zone. The change also fixes a bug that would have made the personal document's zone wrong: after their first sync, personal synced lists ran at the cron time in UTC, not in the node's zone. They now use the zone the document reports.Approach
getCollectionCapabilitiesandgetAdminCollectionCapabilitiesboth gain the two fields. They are reported even when the document's state isnot_configured.mdblist_searchis true when the server has an MDBList API key. MDBList search and top lists now use the same check through one handler method. It does not depend on the account'simportsfeature, because the search route doesn't either. Importing a pasted MDBList link doesn't need the key.schedule_time_zonehasutc_offset(the current±hh:mm, daylight saving time included) andabbreviation(as the time zone database reports it). It also hasnamewhen Go loaded a named zone fromTZ: the IANA name, orUTCwhenTZis empty or names no known zone, matching what Go falls back to.nameis left out when the node uses its system default zone or aTZfile path. Each node reports its own zone.CollectionScheduleTimeZone, notScheduleTimeZone, to keep a generic name out of the/api/v2schema namespace before it locks.Dependencies.ScheduleZone, so the committed fixtures don't depend on the generating machine's zone. Production leaves it unset and reads the local zone.30 4 * * *) ran at 04:30 local the first time and at 04:30 UTC after that.catalog.ComputeNextSyncAtFromnow evaluates the expression in the node's local zone whatever zone the reference time is in, and returns the result in the caller's zone. The admin scheduler, template bundle sync and the first personal run already passed local time, so they behave as before.catalog.ParseCronExpressionrejects robfig/cron'sTZ=andCRON_TZ=prefixes, so admin and library collection writes answer400for them.catalog.ComputeNextSyncAtFromignores a prefix stored before this change, so every schedule runs in the zone the documents report./api/v2responses change./api/v1shares the cron validation, so its collection writes also reject a zone prefix; nothing else on/api/v1changes.docs/catalog-api.mddescribes the fields. The OpenAPI document, the fixtures (including a newget_admin_collection_capabilities_ok), the system-info digest and the web types are regenerated.No web code reads the fields yet; the Synced list step will. jellycompat needs no change. Follow-ups are not filed yet. In
silo-appleandsilo-android: disable MDBList search whenmdblist_searchis false, and label cron times withschedule_time_zone.utc_offset(nameis optional). In the user manual: cron collection schedules run in each node's local zone, so every node should run in one zone.Validation
make lint-changedagainstfeat/api-bundle-template-summariesare clean.make test-gopasses.apiv2,catalog,usercollections,mdblistandapi/handlerspackages ran against a freshly migrated database. The new tests covermdblist_searchon both documents (key set, no key, no import service), the zone fields against the clock, named and unnamed zones including daylight saving time and a half-hour offset, and a personal sync's next run landing at local wall time. They also check that a regular account and a non-primary profile on an admin account both get permission denied on the admin capability document before any feature is read. The new tests also pass withTZ=America/Chicago.TestOrphanCleanupAfterPlexTableDropPostgres,TestAdminSubtitleListPageDBandTestCatalogTransferPersistsJobsAndSignedLink. They fail the same way on the base branch.verify-apiv2-openapi,verify-apiv2-contract(four additive changes, a required response property for each field on each document, nothing breaking),verify-apiv2-fixtures,verify-apiv2-web-types,verify-route-inventory,verify-migration-ledgerandTestCommittedArtifactMatchesRouterpass. So doverify-settings-bindings-all,verify-playback-fixtures,verify-scenario-catalogsandverify-offline-routes.tsc -bandmake test-webpass.make verify-local-pathspasses.Risks
/api/v2: two new required response properties on each capability document. The contract isn't locked yet, and clients that don't know the fields ignore them.next_sync_atalready stored isn't rewritten, so each list runs once more at the old time and follows local time after that. On a node that observes daylight saving time, a daily list runs 23 or 25 hours apart across each change, as admin schedules already do; it still runs at most once a day. Admin schedules don't change.sync_schedulealready carries aTZ=orCRON_TZ=prefix now runs at that time on the node's local clock, and saving that schedule again fails with400until the prefix is removed.TZreportsutc_offsetandabbreviationbut noname.Checklist
AI Disclosure
mdblist_searchto true, dropping the adminschedule_time_zone) to confirm the tests fail. It found one major issue and one nit. The major issue: personal synced lists were rescheduled from a UTC timestamp, so the zone the personal document reported was wrong for them after their first sync. That is fixed inComputeNextSyncAtFrom, with a test that pins the next personal run to local wall time. The nit:namere-readTZthroughtime.LoadLocation, which also consultsZONEINFOand could disagree with the zone Go actually loaded.namenow comes fromtime.Local. No findings remain open.🤖 Generated with Claude Code
Note
Add MDBList search and schedule time zone to collection capability APIs
mdblist_searchandschedule_time_zonefields to the personal and administrator collection capability responses, with newCollectionScheduleTimeZoneschema covering offset, abbreviation, and optional IANA zone name in openapi.json and collection_schedule_zone.goMDBListConfiguredpredicate onCollectionImportServicein personal_collections.go; it returns false when no import service or API key is presentParseCronExpressionrejectsTZ=andCRON_TZ=prefixesParseCronExpressionnow returns an error for zone-prefixed schedules; stored expressions with legacyTZ=/CRON_TZ=prefixes still run but use the node's local zone. OpenAPI consumers must handle the two new required capability fieldsMacroscope summarized 3c52ab3.