interagent / interagent/committee

Cannot assert on actual headers: Rack mutates header key

Open
#262 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Ruby
Stars
955
Forks
145
Avg merge
5d 4h
Merged PRs (30d)
6

Description

Given an OpenApi3 swagger yaml definition for a header:

x-Role: &Role
  in: "header"
  name: "Role"
  required: true
  schema:
    type: "string"
    enum: ["A", "B"]

And given a valid request:

curl ... -H "Role: A"

Committee, when raising an error, raises the following error for this request:

Committee::InvalidRequest:
       #/paths/... missing required parameters: Role

This is because Rack mutates all http headers, and Role becomes HTTP_ROLE.

This would seem unrelated to this gem, except that it is designed as Rack middleware, so it seems odd that it wouldn't work with rack conventions.

I'm not too familiar with the gem yet, but a first idea for a solution might be to cast all swagger-defined headers into HTTP_x formats before passing to validation.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the OpenAPI 3 header example with the shown curl request, then trace the Rack middleware boundary and request-header validation path. Confirm that a required Role header is recognized despite Rack's HTTP_ROLE convention; done means the request validates without the missing-parameter error.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, ruby
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.