This repository was archived by the owner on May 25, 2026. It is now read-only.
feat(schemas): schema-driven slim fields on users (Phase 3b, DOT-560)#111
Merged
Merged
Conversation
Sibling of DOT-558 (Phase 3a). Extends the schema-driven slim-fields pattern (canonical: PR #109, PR #110) to the users domain — the one piece Phase 3a deferred because the slim shape needed a privacy-aware design pass. Slim shape: identity-only — id, username, name, state, avatar_url, web_url, bot. Seven fields. Always safe to expose for any user. Privacy-sensitive fields (email, last_sign_in_at, is_admin, two_factor_enabled, confirmed_at, current_sign_in_at, private_profile, last_activity_on, theme_id, color_scheme_id, projects_limit, external) are excluded by default; opt back in via fields:'all' or explicit pick. A dedicated test pins the privacy guardrail so future expansions of UserSlimShape can't accidentally leak those fields. Phase-1 gaps closed along the way: - src/schemas/users.ts: GitLabUserListSchema didn't exist; add it. - src/tools/users.ts: get_users and search_users were never wrapped with parseGitLabResponse; wrap them now (a prerequisite for typed slim defaults to project from). Wires four user-returning tools with fields + projection: - get_current_user (already parse-wrapped, just adds fields+project) - get_user (already parse-wrapped, just adds fields+project) - get_users (newly parse-wrapped, per-username map slimmed element-wise) - search_users (newly parse-wrapped, list slimmed) Out of scope: list_events, get_project_events, upload_markdown, download_attachment, health_check — they live in users.ts for organizational convenience but don't return user-shaped data. Tests: - tests/schemas/users.test.ts: slim-schema parse, USER_SLIM_FIELDS allow-list invariant, projectField allow-list at runtime, **privacy guardrail** (USER_SLIM_FIELDS does NOT contain email / is_admin / two_factor_enabled / etc.), separate test that projectField actually drops those fields on a populated current-user fixture, GitLabUserListSchema parse, token-budget regression. - tests/users.test.ts: default / fields:'all' / custom-pick handler tests for each of the four tools (12+ cases). get_current_user and get_user tests specifically verify privacy fields absent by default and present under fields:'all'. search_users test confirms `fields` is not forwarded to GitLab as a query string. README "Field Projection" section extended to list the four user endpoints.
Member
Author
|
This change is part of the following stack: Change managed by git-spice. |
ApprovabilityVerdict: Needs human review This PR changes the default response shape of 4 user endpoints to return fewer fields (excluding privacy-sensitive data). While backwards-compatible via You can customize Macroscope's approvability policy. Learn more. |
|
🎉 This PR is included in version 2.32.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Sibling of DOT-558 (Phase 3a). Extends the schema-driven slim-fields
pattern (canonical: PR #109, PR #110) to the users domain — the one
piece Phase 3a deferred because the slim shape needed a privacy-aware
design pass.
Slim shape: identity-only — id, username, name, state, avatar_url,
web_url, bot. Seven fields. Always safe to expose for any user.
Privacy-sensitive fields (email, last_sign_in_at, is_admin,
two_factor_enabled, confirmed_at, current_sign_in_at, private_profile,
last_activity_on, theme_id, color_scheme_id, projects_limit, external)
are excluded by default; opt back in via fields:'all' or explicit pick.
A dedicated test pins the privacy guardrail so future expansions of
UserSlimShape can't accidentally leak those fields.
Phase-1 gaps closed along the way:
with parseGitLabResponse; wrap them now (a prerequisite for typed
slim defaults to project from).
Wires four user-returning tools with fields + projection:
Out of scope: list_events, get_project_events, upload_markdown,
download_attachment, health_check — they live in users.ts for
organizational convenience but don't return user-shaped data.
Tests:
allow-list invariant, projectField allow-list at runtime,
privacy guardrail (USER_SLIM_FIELDS does NOT contain email /
is_admin / two_factor_enabled / etc.), separate test that
projectField actually drops those fields on a populated current-user
fixture, GitLabUserListSchema parse, token-budget regression.
tests for each of the four tools (12+ cases). get_current_user and
get_user tests specifically verify privacy fields absent by default
and present under fields:'all'. search_users test confirms
fieldsis not forwarded to GitLab as a query string.
README "Field Projection" section extended to list the four user
endpoints.
Note
Add schema-driven slim field projection to all four user-returning tools
UserSlimShape,GitLabUserSlimSchema,USER_SLIM_FIELDS, andGitLabUserListSchemato src/schemas/users.ts, exporting a privacy-aware 7-field identity shape (id,username,name,state,avatar_url,web_url,bot).fields: fieldsParam("user").optional()andprojectField/projectFieldsintoget_current_user,get_user,get_users, andsearch_users; all four now return the slim shape by default.get_usersandsearch_userswithparseGitLabResponse(GitLabUserListSchema, ...)for the first time, closing a Phase-1 gap.email,is_admin,two_factor_enabled,last_sign_in_at, etc.) are excluded from the default output and only returned whenfields="all"or explicitly requested.fields="all".🖇️ Linked Issues
Completes DOT-560, which tracks Phase 3b of the response-schema initiative for the users domain. Part of the broader DOT-555 initiative to introduce Zod response schemas as a token-efficiency primitive.
Macroscope summarized f10b61c.