Remove serialization logic from EIS authorization response#144021
Conversation
`ElasticInferenceServiceAuthorizationResponseEntity` is encapsulating the response object EIS returns when ES is polling the authorizations API. The class implements `Writeable` indirectly via `InferenceServiceResults`. This was done so in order to reuse the existing HTTP sender. However, instances are never written to other nodes. This commit removes unnecessary serialization logic. It also adds tests for the `XContent` serialization. Finally, it takes the opportunity to convert the class into a record.
|
Pinging @elastic/search-inference-team (Team:Search - Inference) |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR converts ElasticInferenceServiceAuthorizationResponseEntity and its nested types to Java record types that implement ToXContentObject only, removes stream-based constructors and Writeable serialization (writeTo now unsupported), and drops getAuthorizedEndpoints() in favor of the record accessor authorizedEndpoints(). Tests moved from wire-serialization harness to XContent-based tests. Call sites were updated to use responseEntity.authorizedEndpoints(), and an integration test now seeds JSON responses for semi-random endpoints instead of constructing AuthorizedEndpoint instances in-test. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
jonathan-buttner
left a comment
There was a problem hiding this comment.
Thanks for doing this! I left a comment wondering if we can throw in the top level toXContent() and remove the implements ToXContent* for the nested classes.
| @Nullable String displayName, | ||
| @Nullable String fingerprint | ||
| ) implements Writeable, ToXContentObject { | ||
| ) implements ToXContentObject { |
There was a problem hiding this comment.
Hmm, I don't think the object will serialized to json either 🤔 I might be missing a place though. Could you check and see if we could just throw in the toXContent() of ElasticInferenceServiceAuthorizationResponseEntity? If so we can remove all the others I think to.
There was a problem hiding this comment.
The reason I kept this here is to enable the testing of its parsing side.
There was a problem hiding this comment.
Don't we already have coverage of that in ElasticInferenceServiceAuthorizationResponseEntityTests.testParseAllFields()? I'm not sure we need to be relying on going from Object -> XContent -> Object just to test that we can correctly parse json.
There was a problem hiding this comment.
Ah, I missed that. OK, fair point. I'll remove the toXContent() stuff too and rely on that test instead.
|
@DonalEvans @jonathan-buttner I have now also removed the XContent serialization logic. I have updated the PR title/description to reflect that. |
jonathan-buttner
left a comment
There was a problem hiding this comment.
Looks good, could we keep the toString() methods?
| } | ||
|
|
||
| @Override | ||
| public String toString() { |
There was a problem hiding this comment.
Just curious why we were removing the toString()s? I found them helpful for debugging and I think we log it at debug somewhere 🤔 Maybe that's changed.
There was a problem hiding this comment.
Java records produce equivalent toString(). Only difference is it uses [] instead of {}.
…elocations * upstream/main: (49 commits) CCS logging fixes (elastic#144070) Improve CPS cluster exclusion handling (elastic#143488) Remove snapshot condition now that node_reduce phase is in non-snapshot builds (elastic#144090) Drop deprecation warnings when updating a mapping in the cluster state applier (elastic#143884) (elastic#144040) Add ensureGreenAndNoInitializingShards helper (elastic#144044) Removed unnecessary applies_to blocks from deprecated query (elastic#144096) [CPS] Use single CrossProjectModeDecider instance (elastic#144030) Fix ESQL TS requests with LIMIT 0 (elastic#144031) ESQL: Remove `create` methods in aggs (elastic#144098) ES|QL: Refactor ChangeLimitOperator (elastic#144017) Add Paginated Hit Source Tests (elastic#142592) Fix test failure not preferred (elastic#144019) Remove serialization logic from EIS authorization response (elastic#144021) ESQL: CSV schema inference and parsing enhancements (elastic#144050) ESQL: Fix incorrectly optimized fork with nullify unmapped_fields (elastic#143030) Fix MMR release test using subqueries (elastic#144087) Refactoring `UserAgentPlugin` (elastic#140712) Drop non-finite samples in Prometheus remote write (elastic#144055) [TEST] Wait for internal inference indices to be created in authorization IT (elastic#143885) Disable ndjson datasource QA tests in release-tests (elastic#143992) ...
…44021) `ElasticInferenceServiceAuthorizationResponseEntity` is encapsulating the response object EIS returns when ES is polling the authorizations API. The class implements `Writeable` indirectly via `InferenceServiceResults`. This was done so in order to reuse the existing HTTP sender. However, instances are never written to other nodes. This commit removes unnecessary serialization logic. It also adds tests for the `XContent` serialization. Finally, it takes the opportunity to convert the class into a record.
ElasticInferenceServiceAuthorizationResponseEntityis encapsulating the response object EIS returns when ES is polling the authorizations API. The class is serializable (both wire and XContent) because it implementsInferenceServiceResults. This was done in order to reuse the existing HTTP sender.However, instances are never written to other nodes. Nor are they serialized to XContent.
This commit removes the unnecessary serialization logic.
Finally, it takes the opportunity to convert the class into a record which allows us to further remove some code.