The version header was set from WarpEngine::VERSION_HEADER, a constant introduced in the same commit. The deploy that followed ran these controllers with an older `lib/`, so the before_action raised NameError on every request and every engine endpoint answered 500 — the catalog, the images, the file server and the config extension Woodpecker calls, which is how it surfaced: a pipeline could no longer fetch its own configuration. The controller now spells the header name out. A response header is not worth a dependency that can take the API down when one half of a deploy is older than the other, and the constant remains the documented name with a spec holding the two in step. Confirmed in production mode against the same code that failed: 200 with the header. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
37 lines
1.3 KiB
Ruby
37 lines
1.3 KiB
Ruby
require "rails_helper"
|
|
|
|
# Every response the engine serves carries the version that served it, so a client can
|
|
# branch on the engine's age without asking a separate endpoint for it.
|
|
RSpec.describe "the WarpEngine-Version header", type: :request do
|
|
# The controller writes the name as a literal so that it cannot depend on a constant a
|
|
# half-updated deploy might not have. This is what keeps the two in step.
|
|
it "is the name the constant documents" do
|
|
expect(WarpEngine::VERSION_HEADER).to eq("WarpEngine-Version")
|
|
end
|
|
|
|
it "is on a normal response" do
|
|
create(:software)
|
|
|
|
get "/api/software"
|
|
|
|
expect(response).to have_http_status(:ok)
|
|
expect(response.headers["WarpEngine-Version"]).to eq(WarpEngine::VERSION)
|
|
end
|
|
|
|
# The one a client needs most: something came back wrong, and it wants to know whether
|
|
# the engine on the other end is old enough to explain it. `rescue_from` never reaches
|
|
# an after_action, which is why the header is set before the action runs.
|
|
it "is on an error response" do
|
|
get "/api/image/999999"
|
|
|
|
expect(response).to have_http_status(:not_found)
|
|
expect(response.headers["WarpEngine-Version"]).to eq(WarpEngine::VERSION)
|
|
end
|
|
|
|
it "is on a served file" do
|
|
get "/file/nothing-here.zip"
|
|
|
|
expect(response.headers["WarpEngine-Version"]).to eq(WarpEngine::VERSION)
|
|
end
|
|
end
|