Skip to content

fix: ensure header keys are case-insensitive#251

Merged
PENEKhun merged 3 commits intodevelopfrom
fix/gl-250
Oct 4, 2025
Merged

fix: ensure header keys are case-insensitive#251
PENEKhun merged 3 commits intodevelopfrom
fix/gl-250

Conversation

@PENEKhun
Copy link
Copy Markdown
Member

@PENEKhun PENEKhun commented Oct 4, 2025

ko

표준에 따르면 header key는 대소문자 구분이 되면 안됩니다.
하지만 현재 itdoc에서는 아래와 같은 테스트가 작성되면 내부 동작이 달라질 수 있습니다.

.req()
.header('content-type', ..)
.req()
.header('CONTENT-TYpe', ..)

대소문자 정규화가 되지 않기 때문에, 아래와 같은 코드들이 동작되지 않을 수 있습니다.

image

이런 버그를 수정했습니다.

en

According to the specification, header keys must not be case-sensitive.
However, in itdoc, if tests are written like the following, the internal behavior may differ:

.req()
.header('content-type', ..)
.req()
.header('CONTENT-TYpe', ..)

Because header keys are not normalized, certain code paths may not work as expected:

image

closed #250

Summary by CodeRabbit

  • Bug Fixes
    • Header names are now normalized to lowercase everywhere, and selection of representative results now treats the Authorization header case-insensitively — preventing casing mismatches from altering behavior.
  • Chores
    • Example API specifications updated: header parameters renamed to lowercase for consistency.
  • Documentation
    • Notes updated to indicate header normalization to lowercase.

@PENEKhun PENEKhun requested a review from json-choi October 4, 2025 09:35
@PENEKhun PENEKhun self-assigned this Oct 4, 2025
@PENEKhun PENEKhun added the bug bugbugbug label Oct 4, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Oct 4, 2025

Walkthrough

RequestBuilder.header now normalizes header names to lowercase before assignment (builds a normalizedHeaders map and assigns it to this.config.requestHeaders); method signature and return value unchanged. OpenAPIGenerator selection now checks for an Authorization header case-insensitively by testing for "authorization" in result.request.headers. SecurityBuilder.extractSecurityRequirements likewise uses the lowercase "authorization" key when extracting header values. examples/express/expected/oas.json renamed several header parameter names (e.g., X-Request-ID → x-request-id, Accept → accept, Accept-Language → accept-language). No exported/public signatures changed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the primary change of normalizing header keys to be case-insensitive and aligns directly with the modifications in the request builder and related modules.
Linked Issues Check ✅ Passed The pull request implements case-insensitive header handling by normalizing header names to lowercase in RequestBuilder, adjusting header matching in OpenAPIGenerator and SecurityBuilder, and updating examples to reflect lowercase headers, which fulfills the requirements of issue #250.
Out of Scope Changes Check ✅ Passed All modifications focus exclusively on header key normalization and case-insensitive handling as specified in the linked issue, with no unrelated or extraneous changes introduced.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/gl-250

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 313fc2e and daeb93d.

📒 Files selected for processing (3)
  • examples/express/expected/oas.json (3 hunks)
  • lib/dsl/generator/OpenAPIGenerator.ts (1 hunks)
  • lib/dsl/generator/builders/operation/SecurityBuilder.ts (1 hunks)
🔇 Additional comments (4)
examples/express/expected/oas.json (2)

649-649: LGTM! Header name normalized to lowercase.

The header parameter name has been correctly normalized from X-Request-ID to x-request-id, which aligns with the case-insensitive header handling approach implemented across the codebase.


1191-1200: LGTM! Header names normalized to lowercase.

The header parameter names have been correctly normalized to lowercase (accept and accept-language), which ensures consistent case-insensitive header handling throughout the API specification.

lib/dsl/generator/builders/operation/SecurityBuilder.ts (1)

35-36: LGTM! Authorization header check now case-insensitive.

The change correctly implements case-insensitive header handling by checking for the lowercase "authorization" key, which aligns with the header normalization implemented in RequestBuilder.

lib/dsl/generator/OpenAPIGenerator.ts (1)

493-495: LGTM! Representative result selection now uses normalized header key.

The change correctly checks for the lowercase "authorization" key in headers, ensuring consistent case-insensitive header handling when selecting representative test results for OpenAPI generation.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@PENEKhun PENEKhun changed the title fix: apply header key normalized to lowercase fix: ensure header keys are case-insensitive Oct 4, 2025
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e2bc85 and e0ca8d5.

📒 Files selected for processing (1)
  • lib/dsl/test-builders/RequestBuilder.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
lib/dsl/test-builders/RequestBuilder.ts (1)
lib/dsl/interface/field.ts (1)
  • DSLField (30-34)
🔇 Additional comments (1)
lib/dsl/test-builders/RequestBuilder.ts (1)

28-28: LGTM: Clear documentation of normalization behavior.

The updated docstring accurately describes that header names are normalized to lowercase, which aligns with the HTTP specification's requirement for case-insensitive header handling.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e0ca8d5 and 313fc2e.

📒 Files selected for processing (1)
  • examples/express/expected/oas.json (5 hunks)
🔇 Additional comments (1)
examples/express/expected/oas.json (1)

645-645: Lowercasing header parameter names SGTM

Normalizing header keys to lowercase keeps the OpenAPI document consistent with the new request builder behavior without affecting semantics.

Also applies to: 1183-1183, 1192-1192

@PENEKhun PENEKhun merged commit 0acfa8f into develop Oct 4, 2025
2 checks passed
@PENEKhun PENEKhun deleted the fix/gl-250 branch October 4, 2025 09:57
PENEKhun added a commit that referenced this pull request Oct 5, 2025
* fix: apply header key normalized to lowercase

* update expected oas.json
PENEKhun added a commit that referenced this pull request Oct 6, 2025
* fix: apply header key normalized to lowercase

* update expected oas.json
PENEKhun added a commit that referenced this pull request Oct 9, 2025
* fix: apply header key normalized to lowercase

* update expected oas.json
PENEKhun added a commit that referenced this pull request Oct 26, 2025
* create dsl req().file() for upload single file api

* create fileField dsl sample.

* create examples/express for testing file upload api

* sample tests

* add some validate fileField

* update

* write example itdoc for octstream api

* revert package.json to original

* refactor: fileField remove

now, just direct pass args with
`.req().file(...)`

* test refactor

* clean up

* 기본적인 문서 작성

* review apply. thx rabbit~

* revert it

* review apply. logic fix - thx rabbit~

* logic enhance

* review apply

* fix validate

* apply review : type specific

* fix: ensure header keys are case-insensitive (#251)

* fix: apply header key normalized to lowercase

* update expected oas.json

* revert package.json

* fix logic error
PENEKhun added a commit that referenced this pull request Oct 26, 2025
* create dsl req().file() for upload single file api

* create fileField dsl sample.

* create examples/express for testing file upload api

* sample tests

* add some validate fileField

* update

* write example itdoc for octstream api

* revert package.json to original

* refactor: fileField remove

now, just direct pass args with
`.req().file(...)`

* test refactor

* clean up

* 기본적인 문서 작성

* review apply. thx rabbit~

* revert it

* review apply. logic fix - thx rabbit~

* logic enhance

* review apply

* fix validate

* apply review : type specific

* fix: ensure header keys are case-insensitive (#251)

* fix: apply header key normalized to lowercase

* update expected oas.json

* revert package.json

* fix logic error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug bugbugbug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Case-insensitive header handling for Header Key

2 participants