fix(actors info): handle tiered pay-per-event pricing#1173
Open
l2ysho wants to merge 2 commits into
Open
Conversation
The pricing renderer assumed eventPriceUsd was always a number, but tiered pay-per-event Actors (e.g. lukaskrivka/google-maps-with-contact-details) ship eventTieredPricingUsd instead, so calling .toFixed(2) on undefined crashed `actors info` with exit 1 for these Store Actors. --input / --readme / --json were unaffected because they bypass the pricing renderer. Replace the local PricingInfo interface with apify-client's ActorRunPricingInfo discriminated union, augment ActorChargeEvent locally for the tiered field the SDK doesn't expose yet, and render `from \$X (tiered)` for tiered events. Add an e2e regression test against the actor from the bug report. Fixes #1171 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| const tiered = eventInfo.eventTieredPricingUsd; | ||
| let priceLabel: string; | ||
| if (typeof flat === 'number') { | ||
| priceLabel = `$${flat.toFixed(2)}`; |
Contributor
There was a problem hiding this comment.
toFixed(2) is still problematic for tiered pay-per-event prices because many of these event prices are below one cent. The crash is fixed, but this now renders real prices like 0.005 or 0.00079 as from $0.00 (tiered), which is misleading.
…0.00 Most tiered pay-per-event Actors charge sub-cent prices (e.g. $0.005, $0.00079). toFixed(2) rounded these to "$0.00", so the renderer printed "from $0.00 (tiered)" — making real costs look free. Same problem for flat sub-cent eventPriceUsd, not just tiered. Use 2 decimals when the price is >= $0.01, otherwise 2 significant figures: $0.005 -> "$0.005", $0.00079 -> "$0.00079", $0.25 -> "$0.25". Refs #1171 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
The pricing renderer assumed eventPriceUsd was always a number, but tiered
pay-per-event Actors (e.g. lukaskrivka/google-maps-with-contact-details) ship
eventTieredPricingUsd instead, so calling .toFixed(2) on undefined crashed
actors infowith exit 1 for these Store Actors. --input / --readme / --jsonwere unaffected because they bypass the pricing renderer.
Replace the local PricingInfo interface with apify-client's ActorRunPricingInfo
discriminated union, augment ActorChargeEvent locally for the tiered field
the SDK doesn't expose yet, and render
from \$X (tiered)for tiered events.Add an e2e regression test against the actor from the bug report.
Fixes #1171
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com