Repository navigation
fix(ai): follow-up fixes for the AI API update before release - #426
Merged
Merged
Conversation
Exclude apiKey, headers, serviceAccountKey, the Custom AI key and the Microsoft Foundry deployment apiKey from the Lombok-generated toString() of Credentials and Credentials.Deployment, so logging an AiProvider or AiProviderRequest no longer prints secrets. JSON serialization, equals and the public getters/setters are unchanged. Document the supported provider credential variants and their required fields from the official OpenAPI. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The deprecated Long getLearningRateMultiplier() now returns null for NaN, infinite and out-of-range values instead of clamping them to Long.MAX_VALUE/MIN_VALUE or returning 0; finite values within range are still truncated towards zero, matching Config.getMin()/getMax(). FineTuningJobRequest.Hyperparameters.setLearningRateMultiplierValue() rejects NaN and infinite values, which would otherwise be sent as the invalid JSON strings "NaN"/"Infinity". Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…turn raw gateway bodies as Object - remove AiPromptCompletionData.eta and ProjectAiSettings.preTranslationAiPromptId, added in #424 but deprecated in the API (AiSetting.preTranslationAiPromptId, which is not deprecated, stays) - the deprecated setTools(Map) converts the documented tool shapes ({"tool": {...}} or {"type": "function", "function": {...}}) into the tools array instead of silently dropping the value; any other structure is rejected with IllegalArgumentException - aiGateway*Raw return Object (Map, List, String, Number, Boolean or null) because the gateway response format depends on the provider; an empty body is null and a non-JSON body raises HttpException. Legacy aiGateway* methods are unchanged - fill in missing Javadoc tags Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
SDK 1.37.0 was released with #424, so this follow-up must not change its public API: - keep AiPromptCompletionData.eta and ProjectAiSettings.preTranslationAiPromptId as @deprecated (both are deprecated in the API) instead of removing them - keep the five aiGateway*Raw methods with their released Map<String, Object> signatures and behaviour (JSON object responses only) - add aiGatewayGetJson/PostJson/PutJson/PatchJson/DeleteJson returning any JSON value (Map, List, String, Number, Boolean or null; empty body is null); they have new names, so no overload ambiguity is introduced The credentials toString, setTools(Map) and learningRateMultiplier fixes are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Remove the legacy tools map conversion and its helpers (toAiTools, toTool, requireOnlyKeys, invalidTools). setTools(Map) / getTools() are Lombok accessors again: the map is stored but not sent, exactly as in 1.37.0, and the documented tools array is sent through setAiTools(List). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
andrii-bodnar
approved these changes
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #424, resolving the findings of its post-merge audit. Checked against the official Crowdin OpenAPI specs (full YAML, all four editions).
Release baseline: SDK 1.37.0 has been released, and it includes #424. This PR keeps both source and binary compatibility with the published 1.37.0 artifact; nothing released is removed or changed.
Changes
1. Deprecated fields kept (compatible with 1.37.0)
AiPromptCompletionResponse.AiPromptCompletionData.etaandProjectAiSettings.preTranslationAiPromptIdare deprecated in the API. They stay, marked@Deprecated, as released in 1.37.0.AiSetting.preTranslationAiPromptId(user/organization AI settings) is not deprecated in the API and is unchanged.2.
setTools(Map): 1.37.0 behavior kept, documentedsetTools(Map)/getTools()are the Lombok accessors, exactly as released in 1.37.0. The map is stored and returned bygetTools(), but it is not sent to the API.toolsfield now says so explicitly and points tosetAiTools(List).setAiTools(List<AiTool>), which is sent as the documentedtoolsarray,[{"tool": {"type": "function", "function": {...}}}].aiToolsand threwIllegalArgumentExceptionfor other shapes. That code was removed to keep the class simple. The legacy map never produced a valid request in a released version: 1.36.0 sent it as an object where the API requires an array, and 1.37.0 doesn't send it.3. AI Gateway: new
aiGateway*JsonmethodsThe docs describe the gateway response as "Response from the AI provider (format depends on provider and endpoint)".
aiGateway*Rawmethods keep their exact 1.37.0 signatures (Map<String, Object>) and behaviour. They return a JSON object response as aMap; other formats throwHttpException, as before. Their Javadoc now points to the new methods.aiGatewayGetJson,aiGatewayPostJson,aiGatewayPutJson,aiGatewayPatchJsonandaiGatewayDeleteJsonreturn any JSON value:Map<String, Object>List<Object>String/Number/Booleannull, empty or blank bodynullHttpExceptionwith the raw body ingetHttpResponse()They use new names, so there are no overloads and no null-ambiguity.
aiGatewayGet/Post/Put/Patch/Deleteare unchanged.4. Provider secrets kept out of
toString()@ToString.ExcludeonCredentials.apiKey,headers,serviceAccountKey,keyandCredentials.Deployment.apiKey. PrintingCredentials,AiProviderorAiProviderRequestno longer shows them.equals/hashCodeand the getters/setters.5.
learningRateMultiplieredge casesLong getLearningRateMultiplier()still truncates finite values towards zero. ForNaN, infinite or out-of-Long-range values it now returnsnull, instead of clamping or returning0.FineTuningJobRequest.Hyperparameters.setLearningRateMultiplierValue()rejectsNaN/Infinity, which would otherwise be sent as the invalid JSON strings"NaN"/"Infinity".6. Documentation
Javadoc warnings on the legacy accessors added in #424 are fixed.
Approved behaviour changes (relative to 1.37.0)
Objectreturn type is offered through the newaiGateway*Jsonmethods. The releasedaiGateway*Rawmethods keepMap.Credentials.toString()no longer includes secret values.setTools(Map)is not a behavior change: it behaves exactly as in 1.37.0 (the same code run against the published 1.37.0 classes and this branch prints identical output).Also:
getLearningRateMultiplier()returnsnullfor non-finite or out-of-range values;setLearningRateMultiplierValue()rejectsNaN/Infinity.Validation
./gradlew build): 739 tests, 0 failures, on both JDK 17 and JDK 8.AiGatewayRawHttpTest(8) runs the realApacheHttpClientandJacksonJsonTransformeragainst a local HTTP server. It covers every JSON response type, empty/blank bodies, non-JSON, error status and 204 for theJsonmethods, and the released behaviour of theMap-returningRawmethods (objects work; arrays, scalars, empty and non-JSON bodies throwHttpException). It also checks HTTP methods, Crowdin and Enterprise paths, request bodies and theAuthorizationheader, and the unchanged legacy methods.AIApiTest: the releasedRawtests run unchanged, plus mock tests for all fiveJsonmethods. Theetaand projectpreTranslationAiPromptIdassertions are back.AiPromptCompletionRequestToolsTest(5) covers:setTools(Map)stores the map and sends notools(documented, unexpected, empty andnullmaps).getTools()returns the stored map.setAiTools(List)sends the documented array.toolsproperty is written when both are set.CredentialsTest(3),FineTuningHyperparametersTest(5).crowdin-api-client-java-1.37.0.jar): 0 removed or changed, and no null-ambiguous overloads.master(1.37.0) merged in.Remaining risks
RawandJson) fails in the shared transport (ApacheHttpClientreads a missing entity). This affects every typed SDK call. It's documented in the Javadoc and covered by a test, and needs a separate core fix.setTools(Map)still drops its value silently, as in 1.37.0. This is documented in the Javadoc; usesetAiTools(List).nullvalues inside request maps (for example{"stop": null}) are still dropped by the SDK-wide JSON settings. This is existing behaviour.🤖 Generated with Claude Code