Skip to content

fix(spec-sync): compare published specs against main, not the checked-out branch - #623

Merged
field123 merged 1 commit into
mainfrom
fix/618-baseline-comparison
Sep 23, 2026
Merged

field123 merged 1 commit into
mainfrom
fix/618-baseline-comparison

Conversation

@field123

@field123 field123 commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #618.

Background

This repository publishes TypeScript SDK packages. It generates them from OpenAPI specifications, which are files that describe an API.

Elastic Path publishes its own copy of each specification. A scheduled job downloads them every weekday. When a published specification differs from ours, the job updates our copy, regenerates the client code, and opens a pull request for a person to review.

The problem

The job decided whether a specification needed updating by comparing the published file against the copy on the branch it had checked out. Each specification has its own branch, and the job checks that branch out when it exists.

That comparison is correct while the pull request is open. The branch already holds the update, so the job does not repeat the work.

The comparison is wrong after somebody closes the pull request without merging it, if the branch stays. The branch still holds the update. The main branch does not. Every later run compares the published file against the updated copy, finds them the same, and reports the specification as current.

The specification then stops updating. Nothing fails and nothing warns. The result looks the same as a specification with no upstream changes.

This happened on 2026-09-23. The branch for the settings specification outlived its closed pull request, and the next run skipped that specification.

The fix

Both scripts now compare the published specification against the main branch instead of the checked-out branch. That asks the question the job cares about: does the published file differ from what we released?

A branch that holds a pending update keeps receiving new updates, which is the existing behavior for an open pull request.

The scripts already read SPEC_SYNC_BASELINE to name the reference branch, and it defaults to origin/main. This change reuses that variable rather than adding a second one. The two comparisons must use the same reference. If they differ, the job can compare export names against a commit that never held the specification in question.

A warning for specifications that stop updating

Nothing noticed that a specification had stopped updating. The listing step now compares dates. If the published specification is more than 14 days newer than ours, the run reports it in the job summary. SPEC_SYNC_STALE_DAYS sets the limit.

Evidence

Three cases, each run as a command.

  1. The bug, on main as it is today: a branch carrying the update makes the listing report the specification as current, although main differs from the published file.
  2. The fix, same branch state: the listing reports that the specification needs an update, and gives the age difference.
  3. No new noise: against the real published specifications, all 21 report already current and the listing returns an empty set.

A full run for one specification that does differ regenerates the client, writes a changeset, and exits 0.

For the reviewer

A specification whose pull request stays open now regenerates on every scheduled run. It no longer stops early. A guard still prevents an empty commit, so the cost is build minutes rather than extra pull requests.

If your local copy of the main branch is out of date, a listing run by hand reports merged specifications as changed. Fetch first. Continuous integration is not affected.

@vercel

vercel Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

6 Skipped Deployments
Project Deployment Actions Updated
commerce-essentials Ignored Ignored Preview Sep 23, 2026 4:52pm UTC
composable-frontend-algolia Ignored Ignored Sep 23, 2026 4:52pm UTC
composable-frontend-core Ignored Ignored Preview Sep 23, 2026 4:52pm UTC
composable-frontend-docs Ignored Ignored Preview Sep 23, 2026 4:52pm UTC
composable-frontend-simple Ignored Ignored Preview Sep 23, 2026 4:52pm UTC
composable-frontend-subscriptions Ignored Ignored Preview Sep 23, 2026 4:52pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 56ea60a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

…-out branch

The sync job checks out the spec's long-lived `spec-sync/<spec>` branch when one exists, so
comparing the published spec with the working tree asked whether that branch was up to date
rather than whether `main` was. Correct while the pull request is open; wrong once it is
closed without merging and the branch survives, because the branch carries the refresh, `main`
does not, and every later run reports the spec as current. The spec then stops syncing with no
failure and no warning. `spec-sync/settings` hit this on 2026-09-23.

Both scripts now read the spec from `SPEC_SYNC_BASELINE` (default `origin/main`), the same ref
the export diff already used: one comparison, one knob, and a branch with a pending refresh
keeps being brought up to date, which is the existing intent for an open pull request. A spec
absent from the baseline counts as fully changed. An unresolvable baseline is an error rather
than a silent "everything changed".

`--list` also reports a spec whose published `x-version-timestamp` has run more than
SPEC_SYNC_STALE_DAYS (14) ahead of the baseline, and the workflow raises that in its step
summary. That is the signal this class of failure did not have.

Closes #618
@field123
field123 force-pushed the fix/618-baseline-comparison branch from 0c2ee55 to 56ea60a Compare September 23, 2026 16:51
@field123
field123 marked this pull request as ready for review September 23, 2026 17:01
@field123
field123 merged commit 9599f1a into main Sep 23, 2026
7 checks passed
@field123
field123 deleted the fix/618-baseline-comparison branch September 23, 2026 17:01
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.

A closed spec-sync pull request can stop its spec syncing forever

1 participant