Skip to content

Fix edge response deserialization for non-binary result types#410

Open
timmarkhuff wants to merge 1 commit intomainfrom
tim/fix-result-type
Open

Fix edge response deserialization for non-binary result types#410
timmarkhuff wants to merge 1 commit intomainfrom
tim/fix-result-type

Conversation

@timmarkhuff
Copy link
Contributor

@timmarkhuff timmarkhuff commented Mar 2, 2026

Problem

When submitting an image query to a multi-class (or other non-binary) detector via the edge endpoint, the SDK deserializes the result as BinaryClassificationResult instead of MultiClassificationResult. This happens because:

  1. Edge responses include result_type at the ImageQuery level but omit it from the nested result dict.
  2. Pydantic resolves the Union on ImageQuery.result by trying each type in order. Since result_type is Optional in all result models, BinaryClassificationResult matches first due to having the same shape as MultiClassificationResult.

This causes result_type=None on the result object, spurious "Unrecognized internal label" warnings, and AttributeError when accessing fields specific to the correct result type.

Fix

Added _propagate_result_type which copies the ImageQuery-level result_type into the result dict before Pydantic parsing, so the Union resolves to the correct type. Applied at all three image query deserialization sites: get_image_query, list_image_queries, and submit_image_query.

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