Skip to content

fix: accept imageDownloadHeaders camelCase field name in search() - #1474

Open
mayuriphad wants to merge 1 commit into
marqo-ai:mainlinefrom
mayuriphad:fix/image-download-headers-camelcase-alias
Open

fix: accept imageDownloadHeaders camelCase field name in search()#1474
mayuriphad wants to merge 1 commit into
marqo-ai:mainlinefrom
mayuriphad:fix/image-download-headers-camelcase-alias

Conversation

@mayuriphad

Copy link
Copy Markdown

Summary

SearchQuery.imageDownloadHeaders (components/marqo/src/marqo/tensor_search/models/api_models.py) is declared with alias="image_download_headers", and the docstring/validator comments make clear the intent is: imageDownloadHeaders is the current field name, image_download_headers is kept only as a deprecated alias for backwards compatibility.

But BaseMarqoModel.Config never sets allow_population_by_field_name. In pydantic v1, when a field has an alias, only the alias is accepted as input unless that flag is set — and combined with extra = "forbid", a request actually using the documented camelCase imageDownloadHeaders is rejected outright as an unrecognized field:

pydantic.v1.error_wrappers.ValidationError: 1 validation error for SearchQuery
imageDownloadHeaders
  extra fields not permitted (type=value_error.extra)

So today only the deprecated snake_case name works, which is backwards from the documented behavior.

Fix

Set allow_population_by_field_name = True on BaseMarqoModel.Config. This is the same pattern already used elsewhere in the codebase for exactly this kind of alias (base_model.py, recency_parameters.py), so it's consistent with existing convention. SearchQuery and BulkSearchQuery are the only classes built on BaseMarqoModel, and RecommendQuery (also built on it) declares no aliased fields, so this is scoped to the one place that needed it.

Fixes #401

Test plan

  • Added test_image_download_headers_accepts_camel_case_field_name, asserting SearchQuery(imageDownloadHeaders=...) is accepted and correctly copied into mediaDownloadHeaders
  • Verified the new test fails with exactly the reported extra fields not permitted error when the fix is reverted, and passes with it applied
  • Full tests/unit_tests/marqo/tensor_search/models/test_api_models.py — 71 passed, 45 subtests passed (Python 3.11, per pyproject.toml's requires-python)

SearchQuery declares imageDownloadHeaders with alias="image_download_headers"
for backwards compatibility, but BaseMarqoModel.Config never set
allow_population_by_field_name. Pydantic v1 then only accepts the
alias as input, and with extra = "forbid" a request that actually
uses the documented camelCase field name (imageDownloadHeaders) is
rejected outright as an unrecognized extra field.

Enable allow_population_by_field_name on BaseMarqoModel, matching the
pattern already used by base_model.py and recency_parameters.py, so
both the documented imageDownloadHeaders and the deprecated
image_download_headers alias are accepted.

Fixes marqo-ai#401
Copilot AI lite review requested due to automatic review settings August 26, 2026 17:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

Make image_download_headers lowerCamelCase in API [BUG]

2 participants