diff --git a/libs/ruby/warp_engine/app/controllers/warp_engine/api_controller.rb b/libs/ruby/warp_engine/app/controllers/warp_engine/api_controller.rb index 97577fb..78a93af 100644 --- a/libs/ruby/warp_engine/app/controllers/warp_engine/api_controller.rb +++ b/libs/ruby/warp_engine/app/controllers/warp_engine/api_controller.rb @@ -31,7 +31,13 @@ module WarpEngine private def set_version_header - response.headers[WarpEngine::VERSION_HEADER] = WarpEngine::VERSION + # The name is spelled out here rather than taken from WarpEngine::VERSION_HEADER on + # purpose. A deployed process can end up with these controllers and an older + # `lib/` — it happened on the first deploy of this feature — and a controller that + # needs a constant from the newer half answers 500 to every request instead of + # serving the catalog. A response header is not worth that fragility. The constant + # is still the documented name, and a spec holds the two together. + response.headers["WarpEngine-Version"] = WarpEngine::VERSION end def resolve_mime(path) diff --git a/libs/ruby/warp_engine/spec/requests/version_header_spec.rb b/libs/ruby/warp_engine/spec/requests/version_header_spec.rb index a2818d5..f74304c 100644 --- a/libs/ruby/warp_engine/spec/requests/version_header_spec.rb +++ b/libs/ruby/warp_engine/spec/requests/version_header_spec.rb @@ -3,6 +3,12 @@ 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)