fix(resources): check trial resource limits via the organization trial API#121
Open
pjcdawkins wants to merge 3 commits into
Open
fix(resources): check trial resource limits via the organization trial API#121pjcdawkins wants to merge 3 commits into
pjcdawkins wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the resources:set command’s trial resource-limit advisory check to use the organization trial API instead of the organization profile endpoint, avoiding 403s for orgs migrated to the new billing system.
Changes:
- Replace organization profile-based trial limit checks with
GET /organizations/{id}/trial(limits) +GET /organizations/{id}/usage(current totals), and skip the check unless there’s an active trial. - Tolerate trial/usage fetch errors (debug-only) because the check is advisory and platform-enforced.
- Add integration tests covering no trial, active trial within/exceeding limits, null (uncapped) limits, and “trials not enabled”.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| legacy/src/Command/Resources/ResourcesSetCommand.php | Switches trial limit detection to org /trial + /usage endpoints and skips org fetch with --force. |
| integration-tests/resources_set_trial_test.go | Adds integration coverage for trial-limit behavior and error-tolerant trial endpoint handling. |
| integration-tests/resources_set_test.go | Adjusts an existing test to avoid mocking the removed organization profile call. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…l API
GET /organizations/{id}/profile returns 403 Forbidden for organizations
that have moved to a new billing system, which made resources:set fail
before applying any changes. The profile was only fetched to check the
trial resources_limit, which no longer exists there.
Trial resource limits have moved to GET /organizations/{id}/trial,
regardless of the organization's billing system. Current usage totals
come from GET /organizations/{id}/usage. The check now uses those
endpoints: it applies when the organization has an active trial, and
individual limits may be null, meaning the resource is not capped.
Errors from the trial and usage requests are tolerated because the
check is advisory; limits are enforced by the platform. This also means
trials being unavailable (e.g. for other vendors) is not an error.
Adds integration tests covering: no trial (the gated profile endpoint
must not be requested), an active trial exceeding limits, an active
trial within limits, null (uncapped) limits, and a vendor without
trials.
Written with Claude Code.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The returned arrays are the raw resource_limit and usage totals objects, which contain more keys than cpu, memory and storage. Written with Claude Code. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
6d4894c to
cd88981
Compare
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.
Problem
resources:setfails with403 ForbiddenonGET /organizations/{id}/profilefor organizations that have moved to a new billing system:The profile was only fetched to check the trial
resources_limit, which no longer exists there.Changes
GET /organizations/{id}/trial, which applies regardless of the organization's billing system, with current usage totals fromGET /organizations/{id}/usage. The organization profile is no longer fetched.--force, the organization is no longer fetched at all.Tests
Integration tests cover: no trial (the gated profile endpoint must not be requested), an active trial exceeding limits, an active trial within limits, null (uncapped) limits, and a vendor without trials.
🤖 Generated with Claude Code