fix: align Kotlin sample EUR beneficiary with OpenAPI schema#572
fix: align Kotlin sample EUR beneficiary with OpenAPI schema#572claude[bot] wants to merge 1 commit into
Conversation
The EurBeneficiary schema requires countryOfResidence (not address). Updates buildEurBeneficiary to: - Set countryOfResidence (required field) - Make address optional (not required in schema) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Greptile SummaryThis PR updates
Confidence Score: 3/5The fix correctly removes the hard The samples/kotlin/src/main/kotlin/com/grid/sample/routes/ExternalAccounts.kt — specifically the
|
| Filename | Overview |
|---|---|
| samples/kotlin/src/main/kotlin/com/grid/sample/routes/ExternalAccounts.kt | Aligns EUR beneficiary builder with schema by setting countryOfResidence as required and making address optional, but the fallback chain silently accepts nationality as a substitute for countryOfResidence, undermining the validation guard. |
Sequence Diagram
sequenceDiagram
participant Caller
participant buildEurBeneficiary
participant parseBeneficiaryFields
participant EurBeneficiaryBuilder
Caller->>buildEurBeneficiary: node (JSON with beneficiary data)
buildEurBeneficiary->>parseBeneficiaryFields: node
parseBeneficiaryFields-->>buildEurBeneficiary: "BeneficiaryFields(fullName, nationality=countryOfResidence??nationality, birthDate, address)"
Note over buildEurBeneficiary: val countryOfResidence = node?.optText(countryOfResidence)<br/>?: f.nationality <- may silently use nationality<br/>?: throw IllegalArgumentException
buildEurBeneficiary->>EurBeneficiaryBuilder: beneficiaryType, fullName, countryOfResidence
buildEurBeneficiary->>EurBeneficiaryBuilder: (optional) nationality, birthDate, address
EurBeneficiaryBuilder-->>buildEurBeneficiary: EurBeneficiary
buildEurBeneficiary-->>Caller: EurExternalAccountCreateInfo.Beneficiary
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
samples/kotlin/src/main/kotlin/com/grid/sample/routes/ExternalAccounts.kt:292-294
**Silent fallback from `nationality` to `countryOfResidence`**
`parseBeneficiaryFields` (line 196) sets `f.nationality` to `node.optText("countryOfResidence") ?: node.optText("nationality")`. The fallback chain here means that when `countryOfResidence` is absent but `nationality` is present (e.g., `"nationality": "DE"`), the nationality value is silently used as the country of residence. This bypasses the `IllegalArgumentException` guard entirely despite the validation message. Additionally, `node?.optText("countryOfResidence")` in the first line is redundant — it is always equal to the `countryOfResidence` portion of `f.nationality`, so the first `?:` never changes the outcome.
Reviews (1): Last reviewed commit: "fix: align Kotlin sample EUR beneficiary..." | Re-trigger Greptile
| val countryOfResidence = node?.optText("countryOfResidence") | ||
| ?: f.nationality | ||
| ?: throw IllegalArgumentException("EUR beneficiary requires countryOfResidence") |
There was a problem hiding this comment.
Silent fallback from
nationality to countryOfResidence
parseBeneficiaryFields (line 196) sets f.nationality to node.optText("countryOfResidence") ?: node.optText("nationality"). The fallback chain here means that when countryOfResidence is absent but nationality is present (e.g., "nationality": "DE"), the nationality value is silently used as the country of residence. This bypasses the IllegalArgumentException guard entirely despite the validation message. Additionally, node?.optText("countryOfResidence") in the first line is redundant — it is always equal to the countryOfResidence portion of f.nationality, so the first ?: never changes the outcome.
Prompt To Fix With AI
This is a comment left during a code review.
Path: samples/kotlin/src/main/kotlin/com/grid/sample/routes/ExternalAccounts.kt
Line: 292-294
Comment:
**Silent fallback from `nationality` to `countryOfResidence`**
`parseBeneficiaryFields` (line 196) sets `f.nationality` to `node.optText("countryOfResidence") ?: node.optText("nationality")`. The fallback chain here means that when `countryOfResidence` is absent but `nationality` is present (e.g., `"nationality": "DE"`), the nationality value is silently used as the country of residence. This bypasses the `IllegalArgumentException` guard entirely despite the validation message. Additionally, `node?.optText("countryOfResidence")` in the first line is redundant — it is always equal to the `countryOfResidence` portion of `f.nationality`, so the first `?:` never changes the outcome.
How can I resolve this? If you propose a fix, please make it concise.
Summary
buildEurBeneficiaryin Kotlin sample to match theEurBeneficiaryOpenAPI schemacountryOfResidence(notaddress) as a required fieldaddressoptional since it's not required in the schemaContext
This fix was identified during the documentation sync review of recent schema changes:
ca99dc5- chore: Sync account schemas (chore: Sync account schemas #568)20eb971- [grid] clarify email OTP registration bundle docs ([grid] clarify email OTP registration bundle docs #562)The
EurBeneficiary.yamlschema has:But the Kotlin sample was:
address(which is optional in the schema)countryOfResidence(which is required)Test plan
make lint- passes🤖 Generated with Claude Code