Skip to content

fix(imageopto): correct contrast URL parameter spelling#260

Merged
dgryski merged 1 commit into
fastly:mainfrom
mvanhorn:osc/258-fix-contrast-typo
May 22, 2026
Merged

fix(imageopto): correct contrast URL parameter spelling#260
dgryski merged 1 commit into
fastly:mainfrom
mvanhorn:osc/258-fix-contrast-typo

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Summary

Closes #258. The Contrast option in fsthttp/imageopto/imageopto.go:884 was building URLs with constrast=<value> instead of contrast=<value>. Per Fastly's Image Optimizer reference (https://www.fastly.com/documentation/reference/io/contrast/), the parameter is spelled contrast. The typo meant any user setting Options{Contrast: ...} was silently sending an unknown query parameter that Image Optimizer ignored, so the SDK option has effectively been a no-op since it was introduced.

Why this matters

The reporter noticed it via inspection on line 884. I confirmed against the official IO reference - the canonical parameter name is contrast, not constrast. The existing test on imageopto_test.go:19 was locked to the typo'd output, so the test passing didn't catch that the actual contrast adjustment never reached IO at runtime. Fixing the typo activates the feature that was already documented as supported.

Changes

  • fsthttp/imageopto/imageopto.go:884 - constrast= -> contrast=
  • fsthttp/imageopto/imageopto_test.go:19 - matching expected-URL fixture updated to contrast=-5

No public Go API change (Options.Contrast field name is unchanged). The behavior change is that the parameter now actually reaches the IO service.

How to test

$ go test ./fsthttp/imageopto/...
ok  	github.com/fastly/compute-sdk-go/fsthttp/imageopto	0.284s
$ go build ./...
$ grep -rn constrast --include='*.go' --include='*.md' .
(empty)

Fixes #258

AI-assisted.

The Contrast option in imageopto.go:884 was building URLs with
`constrast=<value>`, but Fastly's Image Optimizer expects the parameter
to be spelled `contrast` (per https://www.fastly.com/documentation/reference/io/contrast/).
The typo meant any user setting `Options{Contrast: ...}` was silently
sending an unknown query parameter that Image Optimizer ignored, so the
SDK option has effectively been a no-op since it was introduced.

Rename the URL parameter to the correct `contrast` spelling in both the
builder (imageopto.go) and the testdata fixture (imageopto_test.go).
The existing test now asserts the correct URL, so `go test
./fsthttp/imageopto/...` exercises the corrected behavior.

Fixes fastly#258

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>

@dgryski dgryski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks.

@dgryski dgryski merged commit 57ef780 into fastly:main May 22, 2026
1 check passed
@mvanhorn

Copy link
Copy Markdown
Contributor Author

Thanks @dgryski for landing the contrast URL parameter spelling fix; constrast had been building the wrong query strings.

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.

Typo in imageopto.go

2 participants