Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix header existence logic, exactly treat as null or empty string #353

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

ysugimoto
Copy link
Owner

This changes are pretty important that improves checking header key existence inside if condition.
In Fastly runtime, the not-set header, means header is not exist will be false in if condition.
However, the empty string value even header key exists, it would be true in if condition.

if (req.http.Foo) {
  log "exists"; // don't output because Foo header is not-set
}
set req.http.Foo = "";
if (req.http.Foo) {
  log "exists2"; // output because Foo header is set with empty string
}

Fastly fiddle: https://fiddle.fastly.dev/fiddle/ed2a5dbb

This bug comes from golang's zero-value relating things... it's very helpful for real world usage but not for reproducing VCL runtime X(

@ysugimoto ysugimoto changed the title fix header existence login, treat as null or empty string fix header existence logic, treat as null or empty string Sep 26, 2024
@ysugimoto ysugimoto changed the title fix header existence logic, treat as null or empty string fix header existence logic, exactly treat as null or empty string Sep 26, 2024
@ysugimoto ysugimoto merged commit 52af080 into main Sep 26, 2024
3 checks passed
@ysugimoto ysugimoto deleted the fix/header-existence branch September 26, 2024 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant