Skip to content

Handle unknown search result kinds without throwing #226 - #227

Merged
kevbite merged 2 commits into
kevbite:masterfrom
JbravoI:master
Sep 11, 2026
Merged

kevbite merged 2 commits into
kevbite:masterfrom
JbravoI:master

Conversation

@JbravoI

@JbravoI JbravoI commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes an edge case in issue #226 where the search response converter throws NotImplementedException when Companies House introduces an unrecognised search result kind.

Changes

  • Added UnknownSearchItem as a generic fallback model.
  • Updated SearchItemConverter to deserialize unknown kind values into UnknownSearchItem.
  • Preserves the raw kind value for callers.
  • Added a regression test covering an unknown search result kind.

Why

Companies House may add new search result types over time. Deserialization should remain forward-compatible instead of failing the entire response when an unfamiliar kind is returned.

Testing

Added scenario test:

SearchAllPayload_DeserializesUnknownKindAsGenericSearchItem

The test verifies that:

  • an unknown search result kind does not throw
  • the item is deserialized as UnknownSearchItem
  • the original kind value is preserved

@kevbite
kevbite self-requested a review September 11, 2026 11:03
@kevbite kevbite self-assigned this Sep 11, 2026
@kevbite

kevbite commented Sep 11, 2026

Copy link
Copy Markdown
Owner

@JbravoI thanks for the contribution, I'll get this merged in!

@kevbite
kevbite merged commit 231ef19 into kevbite:master Sep 11, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants