Skip to content

feat: add slug to v1/listPermissions and v1/getPermission#3466

Merged
mcstepp merged 5 commits intomainfrom
ENG-1879-list-permissions
Jul 7, 2025
Merged

feat: add slug to v1/listPermissions and v1/getPermission#3466
mcstepp merged 5 commits intomainfrom
ENG-1879-list-permissions

Conversation

@mcstepp
Copy link
Collaborator

@mcstepp mcstepp commented Jul 7, 2025

What does this PR do?

Fixes #3452

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • Enhancement (small improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How should this be tested?

Automated tests included

Test 1

  1. Get / v1 / permissions.listPermissions
  2. Slug value for each permission is returned.

Test 2

  1. Get / v1 / permissions.getPermissions
  2. Slug value for specific permission is returned.

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read Contributing Guide
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand areas
  • Ran pnpm build
  • Ran pnpm fmt
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Unkey Docs if changes were necessary

Summary by CodeRabbit

  • New Features

    • Added a new field, slug, to the API responses for permission details and permission lists. This field is now visible in the returned data and documented in the API schema.
  • Tests

    • Updated tests to verify the presence and correctness of the new slug field in API responses.

@linear
Copy link

linear bot commented Jul 7, 2025

@vercel
Copy link

vercel bot commented Jul 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
dashboard ⬜️ Ignored (Inspect) Visit Preview Jul 7, 2025 6:53pm
engineering ⬜️ Ignored (Inspect) Visit Preview Jul 7, 2025 6:53pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 7, 2025

📝 Walkthrough

Walkthrough

The changes add a slug property to the response schemas and payloads of the v1/permissions.getPermission and v1/permissions.listPermissions API endpoints. Corresponding test cases are updated to assert the presence and correctness of the slug field in the returned permission objects.

Changes

Files Change Summary
apps/api/src/routes/v1_permissions_getPermission.ts,
apps/api/src/routes/v1_permissions_listPermissions.ts
Added slug field to API response schemas and response payloads for permission endpoints.
apps/api/src/routes/v1_permissions_getPermission.happy.test.ts,
apps/api/src/routes/v1_permissions_listPermissions.happy.test.ts
Updated tests to assert that the slug property is present and correct in permission responses.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API
    participant DB

    Client->>API: GET /v1/permissions.listPermissions
    API->>DB: Fetch all permissions
    DB-->>API: Permissions (id, name, description, slug)
    API-->>Client: JSON response (includes slug for each permission)

    Client->>API: GET /v1/permissions.getPermission?id=X
    API->>DB: Fetch permission by id
    DB-->>API: Permission (id, name, description, slug)
    API-->>Client: JSON response (includes slug)
Loading

Assessment against linked issues

Objective Addressed Explanation
Add slug field to each permission in /v1/permissions.listPermissions response (#3452)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Suggested reviewers

  • mcstepp
  • perkinsjr
  • ogzhanolguncu

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between efabbf9 and dd8f039.

📒 Files selected for processing (1)
  • apps/api/src/routes/v1_permissions_getPermission.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Test Go API Local / Test (Shard 1/8)
  • GitHub Check: Test Go API Local / Test (Shard 3/8)
  • GitHub Check: Build / Build
  • GitHub Check: Test Go API Local / Test (Shard 6/8)
  • GitHub Check: Test Go API Local / Test (Shard 7/8)
  • GitHub Check: Test API / API Test Local
  • GitHub Check: Test Packages / Test ./packages/api
  • GitHub Check: Test Packages / Test ./packages/hono
  • GitHub Check: Test Packages / Test ./internal/hash
  • GitHub Check: Test Packages / Test ./internal/clickhouse
  • GitHub Check: Test Packages / Test ./packages/rbac
  • GitHub Check: Test Packages / Test ./packages/cache
  • GitHub Check: Test Packages / Test ./apps/dashboard
  • GitHub Check: Test Packages / Test ./internal/encryption
  • GitHub Check: Test Packages / Test ./packages/nextjs
  • GitHub Check: Test Packages / Test ./internal/resend
  • GitHub Check: Test Packages / Test ./internal/id
  • GitHub Check: Test Packages / Test ./internal/billing
  • GitHub Check: Test Packages / Test ./internal/keys
  • GitHub Check: autofix
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
apps/api/src/routes/v1_permissions_getPermission.ts (2)

37-40: LGTM! Schema addition follows established patterns.

The slug field addition to the response schema is well-documented with proper OpenAPI description and example, following the same pattern as other required fields in the schema.


82-82: Slug column NOT NULL constraint confirmed
We’ve verified that in internal/db/src/schema/rbac.ts (line 20) the slug column is declared with .notNull() and enforced unique per workspace. Since permission.slug cannot be null or undefined, no additional null checks are required in the response payload. Approving this change.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@changeset-bot
Copy link

changeset-bot bot commented Jul 7, 2025

⚠️ No Changeset found

Latest commit: dd8f039

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel vercel bot temporarily deployed to Preview – engineering July 7, 2025 17:49 Inactive
@vercel vercel bot temporarily deployed to Preview – dashboard July 7, 2025 17:50 Inactive
@mcstepp mcstepp marked this pull request as ready for review July 7, 2025 17:53
@github-actions
Copy link
Contributor

github-actions bot commented Jul 7, 2025

Thank you for following the naming conventions for pull request titles! 🙏

@mcstepp mcstepp added this pull request to the merge queue Jul 7, 2025
Merged via the queue into main with commit 437cd7d Jul 7, 2025
30 of 39 checks passed
@mcstepp mcstepp deleted the ENG-1879-list-permissions branch July 7, 2025 20:23
@coderabbitai coderabbitai bot mentioned this pull request Jul 8, 2025
18 tasks
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.

The / v1 / permissions.listPermissions endpoint does not return the slug

2 participants