Giving a legacy warehouse export a deadline with HTTP Sunset
A practical reading of RFC 8594 for retiring a CSV export, linking the migration guide and testing the deadline independently of cache policy.
Archive retrospective · Topic year 2019
In this article
Start with the job that still downloads v1
The warehouse owner notices that a nightly job downloads a CSV directly from its v1 address. The replacement export has the same inventory meaning, but it renamed the quantity column. A test that only checks for HTTP 200 can pass for a client that then writes an empty report. To retire the old export safely, the team needs a way to notice that job while it can still download data, give its owner the new field mapping and verify that the replacement writes the same stock balance. RFC 8594, published as an Informational RFC in May 2019, gives the server a field for announcing when a URI will probably stop responding. The example warehouse sets September 30 at noon UTC as a fixed boundary in a fixture. This is a design exercise with a reproducible timestamp. In a real rollout an owner should confirm the cutoff first, since downstream teams may schedule testing and releases against that value.
Make the response useful to an operator
Every successful v1 download carries its announced cutoff and a Link field with the sunset relation. The target is a migration guide, where an operator can find both column names, the compensating process for a failed overnight run and a contact for a team that cannot move in time. The fixture uses a reserved example hostname. It makes no network request to that guide. A production guide should remain available from an address that survives the export's shutdown. Here the announcement applies to the response for one legacy resource. A gateway rule that adds the field to unrelated routes would tell consumers that healthy v2 resources share the same deadline. If an announcement is meant for a larger set, define that set in documentation. Keep the wire value in HTTP-date format and convert to a local display time at the point a person reads the alert.
When new signups stop before downloads stop
The API owner can stop allowing new consumers to register for the old export while serving existing consumers for another quarter. That first decision changes which integrations the owner wants people to choose. The second decision sets a boundary beyond which an old input job can no longer rely on availability. For an existing job, the practical work begins with finding the owner and mapping the new field. Cutover scheduling begins when the team can attach a deadline to that work. RFC 9745 added the Deprecation HTTP response field in 2025. It carries a structured date, while RFC 8594 uses HTTP-date for Sunset. When both are present, Sunset cannot precede Deprecation. A consumer whose log collects both should keep them in separate columns so an inventory of deprecated integrations can be queried independently from the list of upcoming production cutovers.
A five-minute age can outlive the endpoint
One second before the configured deadline, the fixture advertises max-age=300 alongside Sunset. The header describing the URI's future does not rewrite that cache directive. A shared cache could therefore serve a stored response after the origin has stopped generating it. The local test reaches the origin directly and leaves that intermediary behavior unmeasured. For a tightly timed retirement, an owner can shorten freshness near the deadline or flush a known cache entry as a separately verified step. Our origin serves 410 with no-store at the boundary. RFC 8594 leaves the later behavior of the URI open. An operator can distinguish a deliberate 410 from a timeout by preserving the URL and status in the import job's diagnostics. If a header is missing, its absence cannot establish how long the server will remain available.
Step across the boundary on loopback
The script ran on Windows with Node.js v24.19.0. At 11:59:59 UTC the legacy route returned 200, Mon, 30 Sep 2019 12:00:00 GMT, the documentation link, max-age=300 and a CSV heading of sku,on_hand. Advancing the injected clock by exactly one second yielded 410 and no-store. On the same process the v2 route returned 200 and sku,quantity, with no Sunset value. The assertions ran against real HTTP responses on a loopback socket before the process closed the server. The document dates from 2019. The fixture uses modern Node and its built-in fetch, and no 2019 Node release or shared cache was exercised. An injected clock lets a future test run reproduce the boundary without changing the machine clock or waiting until a particular day.
import assert from 'node:assert/strict';
import { once } from 'node:events';
import { createServer } from 'node:http';
const cutoff = new Date('2019-09-30T12:00:00Z');
const legacy = '/exports/v1/warehouse.csv';
const oldReport = '/exports/v2/warehouse.csv';
const cachePolicy = 'max-age=300';
let now = Date.parse('2019-09-30T11:59:59Z');
const server = createServer((request, response) => {
if (request.url === oldReport) {
response.writeHead(200, { 'Cache-Control': cachePolicy });
return response.end('sku,quantity\nA17,8\n');
}
if (request.url !== legacy) {
response.writeHead(404);
return response.end();
}
if (now >= +cutoff) {
response.writeHead(410, { 'Cache-Control': 'no-store' });
return response.end('Legacy export retired');
}
response.writeHead(200, {
Sunset: cutoff.toUTCString(),
Link: '<https://docs.example.org/exports/v1-retirement>; rel="sunset"',
'Cache-Control': cachePolicy,
});
response.end('sku,on_hand\nA17,8\n');
});
server.listen(0, '127.0.0.1');
await once(server, 'listening');
try {
const origin = 'http://127.0.0.1:' + server.address().port;
const observe = async path => {
const response = await fetch(origin + path);
return {
status: response.status,
sunset: response.headers.get('sunset'),
cache: response.headers.get('cache-control'),
docs: response.headers.get('link'),
body: (await response.text()).split('\n')[0],
};
};
const before = await observe(legacy);
assert.deepEqual(before, {
status: 200, sunset: 'Mon, 30 Sep 2019 12:00:00 GMT',
cache: 'max-age=300',
docs: '<https://docs.example.org/exports/v1-retirement>; rel="sunset"',
body: 'sku,on_hand',
});
now += 1000;
const at = await observe(legacy);
assert.equal(at.status, 410);
assert.equal(at.cache, 'no-store');
const v2 = await observe(oldReport);
assert.equal(v2.status, 200);
assert.equal(v2.sunset, null);
assert.equal(v2.body, 'sku,quantity');
console.log(JSON.stringify({ runtime: process.version, before, at, v2 }, null, 2));
} finally {
server.close();
}
What to compare when v2 starts writing stock
Run a shadow import from v2, and compare row counts together with the per-product balance before changing the destination job. A total alone could hide stock mapped to the wrong SKU. Record the source version on each import so a team can find remaining v1 jobs across warehouses. After switching a job over, verify the alert it sends when a row lacks quantity and confirm that the import cannot erase yesterday's table on a failed download. The last observation worth keeping is a successful download from the replacement after the old route's cutoff. That check catches a gateway rule applied to both versions or a shared credential revoked too early. Keep the guide available during support for the remaining consumers. The team can retire the alert once it has observed the intended v2 reads and accounted for the owners of the last v1 jobs.
Reader discussion
Which data would you verify before applying this development in your field?
No comments yet. Be the first to contribute.
Write a comment