Repository navigation
STF-2532: Deprecate ShippingAddress.isHighRisk - #2001
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the deprecation of ShippingAddress.isHighRisk.
No open issues 🎉
What changed in this PR
Deprecates ShippingAddress.isHighRisk ahead of the minFraud web service removing the field, while preserving the existing boolean type for source compatibility.
Changes:
- Adds deprecation annotations to the public and raw response interfaces, announcing removal in version 10.0.0.
- Replaces the incorrect public property description with guidance not to rely on the field.
- Records the deprecation in the unreleased changelog.
| File | Description |
|---|---|
src/response/web-records.ts |
Marks is_high_risk as deprecated. |
src/response/records.ts |
Deprecates isHighRisk and corrects its documentation. |
CHANGELOG.md |
Announces the deprecation and planned removal. |
Review effort: Balanced
The minFraud web service is removing shipping_address.is_high_risk from its responses. Mark the property deprecated for removal in 10.0.0. Keep its type, because widening it to optional could break code that compiles today. The old comment described is_in_ip_country. Replace it with the deprecation notice. STF-2532 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
10f0a16 to
6ad7a2a
Compare
horgh
left a comment
There was a problem hiding this comment.
Looks good. Most of Claude's comments don't look important and I ignored them on the other PRs I've looked at so far. There is at least one that seems worth looking at though.
| * @category Deprecated | ||
| * @deprecated This property will be removed in 10.0.0. | ||
| */ | ||
| readonly isHighRisk: boolean; |
There was a problem hiding this comment.
The comment above says this property is undefined when the web service does not return it, but the type is still boolean. The PR description gives the reason: a change to isHighRisk?: boolean can break code that compiles today.
But the web service already leaves out shipping_address.is_high_risk for some requests that have a shipping address. After STF-2444 deploys, it leaves the field out for all requests. So the boolean type is already wrong at runtime for some responses. With strictNullChecks, code such as addr.isHighRisk.toString() or const risky: boolean = addr.isHighRisk compiles and then throws or gets undefined. A compile error would point users to code that is already broken. Email.isHighRisk (line 291) is already optional.
Consider readonly isHighRisk?: boolean here and readonly is_high_risk?: boolean in ShippingAddressWebRecord (src/response/web-records.ts). If you keep boolean on purpose for semver, that is a fair tradeoff. In that case, see the CHANGELOG comment.
🤖 Comment by Claude Opus 5.5.
There was a problem hiding this comment.
Seems like it is intentional to leave it.
There was a problem hiding this comment.
Yeah, this is intentional as changing it would be a breaking change. I agree that it was wrong, but it is deprecated now and we will be removing it.
|
|
||
| * Deprecated the `isHighRisk` property on `response.shippingAddress`. The | ||
| minFraud web service is removing the `shipping_address.is_high_risk` field | ||
| from its responses. The property will be removed in 10.0.0. |
There was a problem hiding this comment.
This entry says that 10.0.0 removes the property. It does not say that the value can be undefined before then. The web service already leaves out shipping_address.is_high_risk for some requests that have a shipping address. After the web service change deploys, the property is undefined in all responses, whatever library version the user has. The TypeScript type stays boolean, so users who read only the CHANGELOG can think the value stays valid until they upgrade to 10.0.0.
Suggest a sentence such as: "The property is undefined when the web service does not return the field. This already happens for some requests, and will happen for all requests once the web service change deploys."
🤖 Comment by Claude Opus 5.5.
| * could not be geolocated, then the property is `null`. | ||
| * This is `true` if the shipping address is associated with fraudulent | ||
| * transactions. The minFraud web service deprecated this field. This is | ||
| * `undefined` when the web service does not return it. |
There was a problem hiding this comment.
Nit: no test covers the undefined case that this comment describes. The shipping address assertions in src/webServiceClient.spec.ts (lines 329, 590, 697) use only the fixture that has is_high_risk: true. Consider a case that removes shipping_address.is_high_risk from the response and asserts that got.shippingAddress?.isHighRisk is undefined and that the other shipping address properties still map. The web service already leaves out the field for some requests, so this case becomes the normal one.
🤖 Comment by Claude Opus 5.5.
| * @deprecated This property will be removed in 10.0.0. | ||
| */ | ||
| readonly isHighRisk: boolean; | ||
| /** |
There was a problem hiding this comment.
Pre-existing, not caused by this PR: the new isHighRisk comment correctly says undefined for a missing field. The comments on isPostalInCity (line 350) and isInIpCountry (line 373) say the property "will be null". The client does not add missing keys (maybeGet only runs camelcaseKeys), so the value is undefined. BillingAddress.isPostalInCity (line 383) and BillingAddress.isInIpCountry (line 402) have the same text. The comments in this interface now disagree. Optional follow-up: change "will be null" to "is undefined".
🤖 Comment by Claude Opus 5.5.
There was a problem hiding this comment.
That might be worth fixing given we fixed it for this one?
There was a problem hiding this comment.
Comment from Claude Opus 5.5, an agent working on behalf of Greg.
Fixed in 01b173b. The isPostalInCity and isInIpCountry comments on BillingAddress and ShippingAddress now say undefined, not null.
| * @deprecated This property will be removed in 10.0.0. | ||
| */ | ||
| readonly isHighRisk: boolean; | ||
| /** |
There was a problem hiding this comment.
Pre-existing, not caused by this PR: latitude, longitude, distanceToIpLocation, and distanceToBillingAddress (lines 356-368) are typed as always present (number). I believe the web service leaves them out when it cannot locate the address, but please confirm. If it does, code such as addr.distanceToIpLocation > 500 compiles, and at runtime compares undefined, which is always false. BillingAddress and the *WebRecord types have the same shape. A fix probably belongs in 10.0.0 if the team treats it as a breaking type change.
🤖 Comment by Claude Opus 5.5.
There was a problem hiding this comment.
Yeah, I'll make an issue for this.
There was a problem hiding this comment.
Comment from Claude Opus 5.5, an agent working on behalf of Greg.
Filed as ENG-5895. I checked the web service code: it can leave out these address fields. The issue also lists the other Node response properties that are typed as always present but that the service can leave out, for example on the credit card, phone, email, and device. The fix is a breaking type change, so it is planned for 10.0.0.
| * shipping address could not be parsed or was not provided or the IP address | ||
| * could not be geolocated, then the property is `null`. | ||
| * This is `true` if the shipping address is associated with fraudulent | ||
| * transactions. The minFraud web service deprecated this field. This is |
There was a problem hiding this comment.
Nit: this comment says the web service "deprecated this field", but the CHANGELOG entry says the web service "is removing" it from its responses. "Deprecated" can suggest that the web service still sends the field. The web service already leaves the field out of some responses, and after the change it leaves it out of all responses.
Suggest the CHANGELOG wording here, for example: "The minFraud web service is removing this field from its responses. This is undefined when the web service does not return it."
🤖 Comment by Claude Opus 5.5.
| 9.3.0 (unreleased) | ||
| ------------------ | ||
|
|
||
| * Deprecated the `isHighRisk` property on `response.shippingAddress`. The |
There was a problem hiding this comment.
Nit, optional: when this library deprecated the Factors subscores (8.0.0), the CHANGELOG entry linked to the minFraud release notes. Consider a link to the release note for this removal, so users can find the date and the reason. If this release ships before that release note is published, ignore this.
🤖 Comment by Claude Opus 5.5.
The client does not add keys that the web service leaves out, so a missing isPostalInCity or isInIpCountry is undefined, not null. This matches the new isHighRisk comment. STF-2532 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
ShippingAddress.isHighRiskwith@deprecated. The minFraud web service is removingshipping_address.is_high_riskfrom its responses. Version 10.0.0 removes it.is_in_ip_country. The type staysboolean, because a change to optional can break code that compiles today.The deprecation can release before the web service change deploys.
STF-2532
🤖 Generated with Claude Code
Summary by CodeRabbit
undefinedwhen the service omits the relevant information, rather thannull.