Skip to content

fix(teams): allow 81-character roles on team create - #13944

Merged
HarshMN2345 merged 3 commits into
mainfrom
fix/issue-8051
Sep 29, 2026
Merged

HarshMN2345 merged 3 commits into
mainfrom
fix/issue-8051

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

createTeam validated roles with a bare new Key(), which defaults maxLength to Database::MAX_UID_DEFAULT_LENGTH (36), while its description claimed 32. So the documented limit was wrong either way, and a role that createMembership and updateMembership accept was rejected at createTeam.

Those two actions already allowed 81 characters: a project-scoped role, project-<projectId>-<role>, is 9 template characters around two 36-character IDs. But each spelled it as a bare 81, repeated 81 in its parameter description, and carried the same comment explaining the arithmetic.

This names the limit once as APP_LIMIT_ROLE_LENGTH in app/init/constants.php, beside the other APP_LIMIT_* values, and uses it in all three actions for both the validator and the description. The validators and the documented limit can no longer drift apart, which is how createTeam ended up at 36 while claiming 32. The rendered descriptions are unchanged, so the generated specs do not move.

utopia-php/database's Roles validator also allows 81 for the same reason (Validator/Roles.php). It is a vendored library and cannot reference an Appwrite constant, so it stays as it is; the two agree today.

Storage is unaffected: the memberships roles attribute is size 128 in app/config/collections/common.php.

Test Plan

  • composer lint on all five changed files, vendor/bin/rector --dry-run on the test, and phpstan on the three actions: all clean.
  • testCreateTeam now sends a project-scoped role, project-<ID>-developer, which is 38 characters: longer than the old 36-character limit, so it fails before this change, without restating the limit in the test. On the client and console sides it then reads the creator's membership back and checks the role was saved. An API key creates a team without a creator membership, so the server side checks the 201 only. The creator always gets owner as well, so the check is that the role is contained, not that it is the only one.

Not run: the e2e needs the Docker stack, which was not available here.

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs? — createTeam's description moves from "32" to "81", which is the only rendered change; the two membership descriptions render the same as before

createTeam validated roles with a bare Key(), capping them at 36 chars
while createMembership and updateMembership already allow 81, so a role
accepted on a membership was rejected on the team that owns it. The
param description also claimed 32.
@ghost

ghost commented Sep 28, 2026 •

Copy link
Copy Markdown

🔵 Tier A · Mergeable after minor fixes

The API change appears consistent, but the revised regression test no longer checks the 81-character boundary.

Team creation now accepts roles up to 81 characters, matching membership creation and updates. The pull request also updates the API descriptions and adds a team-creation E2E case that checks the creator’s persisted role.

Latest changes: The newest commits centralize the 81-character limit in a shared constant and change the E2E case from an 81-character string to a project-shaped role checked through the memberships API.

Verdict New comments Fixed Still open
✅ Approved 1 0 0
Finding Where
🟡 Keep the E2E role at the 81-character boundary tests/e2e/Services/Teams/TeamsBase.php:170
📂 Walkthrough · 5
File Change
app/init/constants.php Defines a shared 81-character team-role limit.
src/Appwrite/Platform/Modules/Teams/Http/Memberships/Create.php Uses the shared limit for role validation and its API description.
src/Appwrite/Platform/Modules/Teams/Http/Memberships/Update.php Uses the shared limit for role validation and its API description.
src/Appwrite/Platform/Modules/Teams/Http/Teams/Create.php Raises team-creation role validation to the shared limit and updates its API description.
tests/e2e/Services/Teams/TeamsBase.php Creates a team with a project-shaped role and checks that the creator membership retains it.

Reviewed the commits since 0897f98 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@greptile-apps

greptile-apps Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Increases the maximum length allowed for team roles.

The PR appears safe to merge; no outstanding finding or accepted new issue remains.

Summary

The PR raises the team-creation role limit to match the membership endpoints and uses a shared constant for their validators and descriptions. The team-creation test uses a project-scoped role and checks that the creator’s membership retains it.

Reviews (3) · Last reviewed commit: "Merge branch 'main' into fix/issue-8051"

Comment thread tests/e2e/Services/Teams/TeamsBase.php Resolved
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/issue-8051 (after).

⚠️ Before benchmark did not complete — change column unavailable.

⚠️ Current branch benchmark did not complete — showing available metrics only.

Metric Before After Change
🚀 Requests/sec n/a n/a n/a
⏱️ Latency P50 n/a n/a n/a
⏱️ Latency P95 n/a n/a n/a
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total n/a n/a n/a n/a n/a
Account n/a n/a n/a n/a n/a
TablesDB n/a n/a n/a n/a n/a
Storage n/a n/a n/a n/a n/a
Functions n/a n/a n/a n/a n/a

Top API waits (after)

API request Max wait (ms)
n/a n/a

Team create and both membership actions each spelled the role limit as a
bare 81, repeated it in their parameter descriptions, and carried the
same comment explaining where it comes from. Define it once as
APP_LIMIT_ROLE_LENGTH and use it in all three, so the validators and the
documented limit cannot drift apart. The rendered descriptions are
unchanged.

The create-team test now sends a project-scoped role longer than a bare
ID, rather than a string built to the limit, and reads the creator's
membership back to confirm the role was saved.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · Looks good to merge. Summary

$this->assertEquals(true, $dateValidator->isValid($response3['body']['$createdAt']));

// A project-scoped role is longer than a bare ID
$role = 'project-' . ID::unique() . '-developer';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the E2E role at the 81-character boundary

Replacing the 81-character string with an ID::unique()-based role no longer exercises the advertised limit. The test would still pass if the validator were lowered to a value between this shorter role’s length and 81, so please construct a project-shaped role of exactly 81 characters.

Suggested change
$role = 'project-' . ID::unique() . '-developer';
$role = 'project-' . str_repeat('a', 36) . '-' . str_repeat('b', 36);

🟡 Minor · testing · Reply if this doesn't apply.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IS THIS an established pattren?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not as a Teams-specific pattern, no. I should have framed the suggestion as boundary coverage, not an established convention. There is a similar max-length E2E test using str_repeat() in tests/e2e/Services/Project/LabelsBase.php:119-126.

Your current test already catches the original create-team bug by sending a role longer than 36 characters (tests/e2e/Services/Teams/TeamsBase.php:169-180). My suggestion would additionally catch a future change that accepts that shorter role but rejects the documented 81-character maximum (src/Appwrite/Platform/Modules/Teams/Http/Teams/Create.php:65). It’s a useful improvement, not a claim that your regression test is invalid.

@HarshMN2345
HarshMN2345 merged commit 51fdce9 into main Sep 29, 2026
50 of 51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀 Enhancement: Increase the word length of Team Role Parameter into 50 or 100

1 participant