fix: fix E2E test drift caused by api_token#276
Merged
tamas-jozsa merged 1 commit intomainfrom Apr 15, 2026
Merged
Conversation
…ordering The v5 provider returns permission_groups sorted alphabetically by ID, but the migrator preserved the original v4 ordering. This caused drift in E2E tests where the plan showed IDs swapped between what the config specified and what the provider expected.
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.
Summary
api_tokenpermission_groupsordering mismatch between migrated config and v5 provider canonical orderingProblem
The v5 Cloudflare provider returns
permission_groupssorted alphabetically by ID, but the migrator preserved the original v4 ordering verbatim. This produced 4 unexempted drift changes in E2E tests where the plan showed permission group IDs swapped:Affected resources:
basic_token,multi_perms_token(any token with 2+ permission groups in a single policy).Fix
Sort
permission_groupsIDs alphabetically intransformPermissionGroups()before building the v5 object list. This matches the v5 provider's canonical ordering and eliminates drift for all users, not just E2E tests.Changes
internal/resources/api_token/v4_to_v5.go— Collect all permission group IDs first,sort.Strings(), then build objectsinternal/resources/api_token/v4_to_v5_test.go— Update 2 test expected outputsintegration/v4_to_v5/testdata/api_token/expected/api_token.tf— Update 2 expected outputsTesting
go test ./...passes with zero failures