Skip to content

feat: add db search to externalId#3315

Merged
ogzhanolguncu merged 11 commits intomainfrom
add-db-search-to-externalid
Jun 24, 2025
Merged

feat: add db search to externalId#3315
ogzhanolguncu merged 11 commits intomainfrom
add-db-search-to-externalid

Conversation

@ogzhanolguncu
Copy link
Contributor

@ogzhanolguncu ogzhanolguncu commented Jun 11, 2025

What does this PR do?

  • Adds db search to externalId creation combobox

Fixes # (issue)

If there is not an issue for this, please create one first. This is used to tracking purposes and also helps use understand why this PR exists

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?

Test: Try to search for something in the externalId dropdown that hasn't been loaded yet. If it's not in the memory dropdown should make a rpc call.

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 searchable, paginated combobox for selecting or creating external identities with improved user feedback.
    • Introduced animated loading and empty states, enhanced accessibility, and UX improvements for identity selection.
  • Bug Fixes

    • Ensured the current identity is always included in the selection options, even if missing from search results.
  • Improvements

    • Reduced the default number of identities fetched initially for better performance.
    • The "Create" option now appears conditionally based on search input and results.
    • Enhanced loading and searching indicators for clearer user experience.
    • Included external ID tracking in key owner updates for more precise identity management.
    • Refreshed identity search cache after creating new identities to keep data up-to-date.
  • API Updates

    • Added a new identity search endpoint for efficient and precise lookups.
    • Extended support for external IDs when updating key owners.

@changeset-bot
Copy link

changeset-bot bot commented Jun 11, 2025

⚠️ No Changeset found

Latest commit: 6e41a6c

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
Copy link

vercel bot commented Jun 11, 2025

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

Name Status Preview Comments Updated (UTC)
dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 24, 2025 5:55pm
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 24, 2025 5:55pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 11, 2025

📝 Walkthrough

Walkthrough

This change introduces asynchronous identity searching to the ExternalIdField component, adds a new TRPC search endpoint and hook, and updates related logic to handle external IDs more robustly. It modifies the key owner update flow to support external IDs, adjusts cache invalidation, and exports relevant schemas for broader use.

Changes

File(s) Change Summary
.../external-id-field/index.tsx, .../edit-external-id/index.tsx Enhanced ExternalIdField with async search, paginated loading, create option, updated onChange signature; updated usage to support new props/signature.
.../external-id-field/use-search-identities.tsx Added new debounced identity search hook using TRPC.
.../hooks/use-create-identity.ts Added cache invalidation for identity search after identity creation.
.../hooks/use-fetch-identities/index.ts Changed default fetch limit to 10 via constant.
.../routers/identity/query.ts Exported IdentityResponseSchema for external use.
.../routers/identity/search.ts Introduced new TRPC procedure for searching identities by external ID with input validation and rate limiting.
.../routers/index.ts Added search route to the identity router.
.../routers/key/updateOwnerId.ts Extended owner validation and update logic to include optional externalId.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ExternalIdField
    participant useSearchIdentities
    participant TRPC_Server

    User->>ExternalIdField: Types in search input
    ExternalIdField->>useSearchIdentities: Passes search query
    useSearchIdentities->>TRPC_Server: searchIdentities(query)
    TRPC_Server-->>useSearchIdentities: Returns matching identities
    useSearchIdentities-->>ExternalIdField: Provides searchResults, isSearching
    ExternalIdField-->>User: Updates combobox options

    User->>ExternalIdField: Selects or creates identity
    ExternalIdField->>ParentComponent: onChange(identityId, externalId)
Loading

Possibly related PRs

  • fix: add create for partial matches #3256: The main PR and the retrieved PR both modify the ExternalIdField component to handle partial matches by showing a "Create" option for new identities when the search input partially matches existing identities but has no exact match, making their changes directly related.
  • refactor: add ownerId to create key for backward compat #3312: Both PRs modify the ExternalIdField component’s onChange prop to accept two parameters and update key creation logic to include ownerId from externalId; thus, both PRs relate to handling identity and external ID data together.
  • feat: keys multiple selection #3234: Both PRs modify the edit-external-id component to handle external ID changes and update the component to use the new ExternalIdField with dual state for identity and external ID, indicating a strong code-level relation.

Suggested reviewers

  • perkinsjr
  • mcstepp
  • chronark

📜 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 29f7520 and 6e41a6c.

📒 Files selected for processing (2)
  • apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/index.tsx (1 hunks)
  • apps/dashboard/lib/trpc/routers/index.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/index.tsx (1)
Learnt from: ogzhanolguncu
PR: unkeyed/unkey#3315
File: apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/general-setup.tsx:40-50
Timestamp: 2025-06-19T13:01:55.338Z
Learning: In the create-key form's GeneralSetup component, the Controller is intentionally bound to "identityId" as the primary field while "externalId" is set explicitly via setValue. The ExternalIdField component has been designed to handle this pattern where it receives identityId as its value prop but manages both identityId and externalId through its onChange callback.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Test Packages / Test ./internal/clickhouse
🔇 Additional comments (1)
apps/dashboard/lib/trpc/routers/index.ts (1)

39-39: LGTM! Clean integration of the search functionality.

The import and route addition follow the established patterns and integrate properly with the existing router structure.

Also applies to: 295-295

✨ 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.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 11, 2025

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

Copy link
Contributor Author

@chronark This is for fireworks, since they have 12321312312321 identities its impossible for them to find it without a db call. We can merge this after ownerID pr

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 8

🧹 Nitpick comments (5)
apps/dashboard/lib/trpc/routers/index.ts (1)

26-27: Import order nit – optional

The new searchIdentities import is inserted mid-block, breaking the existing (mostly) alpha order of the identity‐related imports above/below. Not critical but keeping a consistent order eases merge conflicts.

-import { queryIdentities } from "./identity/query";
-import { searchIdentities } from "./identity/search";
+import { queryIdentities } from "./identity/query";
+import { searchIdentities } from "./identity/search";
apps/dashboard/lib/trpc/routers/key/create.ts (1)

50-52: Null-coalesce nullable columns before insert

identityId and ownerId are optional in the incoming payload.
Passing undefined instead of null may cause the ORM to omit the column or break when the DB column is declared NULL DEFAULT NULL.

-          identityId: input.identityId,
-          ownerId: input.externalId,
+          identityId: input.identityId ?? null,
+          ownerId: input.externalId ?? null,

Keeping the assignment explicit also makes the intent clearer.

apps/dashboard/lib/trpc/routers/key/updateOwnerId.ts (1)

198-199: Use ?? null when persisting optional fields

For consistency with the V1 path (and to avoid accidentally writing undefined), coalesce the two assignments:

-          identityId: input.identity.id ?? null,
-          ownerId: input.identity.externalId,
+          identityId: input.identity.id ?? null,
+          ownerId: input.identity.externalId ?? null,
apps/dashboard/lib/trpc/routers/identity/search.ts (2)

31-36: Remove redundant query validation

This validation is redundant as the input schema already validates that the query is non-empty through .min(1) and the whitespace refinement.

-    if (!query.trim()) {
-      throw new TRPCError({
-        code: "BAD_REQUEST",
-        message: "Search query cannot be empty",
-      });
-    }

60-68: Remove unnecessary data transformation

The transformation logic is redundant as the data already matches the expected format. The null coercion for updatedAt can be handled by the schema validation.

-      const transformedIdentities = identitiesQuery.map((identity) => ({
-        id: identity.id,
-        externalId: identity.externalId,
-        workspaceId: identity.workspaceId,
-        environment: identity.environment,
-        meta: identity.meta,
-        createdAt: identity.createdAt,
-        updatedAt: identity.updatedAt ? identity.updatedAt : null,
-      }));
-
       return {
-        identities: transformedIdentities,
+        identities: identitiesQuery,
       };
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7fb87a8 and fa0d03d.

📒 Files selected for processing (14)
  • apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/index.tsx (7 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/use-search-identities.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/general-setup.tsx (2 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.schema.ts (2 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.utils.ts (2 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-create-identity.ts (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/index.ts (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-external-id/index.tsx (3 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls/components/batch-edit-external-id.tsx (4 hunks)
  • apps/dashboard/lib/trpc/routers/identity/query.ts (1 hunks)
  • apps/dashboard/lib/trpc/routers/identity/search.ts (1 hunks)
  • apps/dashboard/lib/trpc/routers/index.ts (2 hunks)
  • apps/dashboard/lib/trpc/routers/key/create.ts (1 hunks)
  • apps/dashboard/lib/trpc/routers/key/updateOwnerId.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
apps/dashboard/lib/trpc/routers/key/create.ts (1)
Learnt from: chronark
PR: unkeyed/unkey#2693
File: apps/api/src/routes/v1_keys_updateKey.ts:350-368
Timestamp: 2024-11-29T15:15:47.308Z
Learning: In `apps/api/src/routes/v1_keys_updateKey.ts`, the code intentionally handles `externalId` and `ownerId` separately for clarity. The `ownerId` field will be removed in the future, simplifying the code.
apps/dashboard/lib/trpc/routers/key/updateOwnerId.ts (1)
Learnt from: chronark
PR: unkeyed/unkey#2693
File: apps/api/src/routes/v1_keys_updateKey.ts:350-368
Timestamp: 2024-11-29T15:15:47.308Z
Learning: In `apps/api/src/routes/v1_keys_updateKey.ts`, the code intentionally handles `externalId` and `ownerId` separately for clarity. The `ownerId` field will be removed in the future, simplifying the code.
🧬 Code Graph Analysis (4)
apps/dashboard/lib/trpc/routers/identity/search.ts (3)
apps/dashboard/lib/trpc/routers/identity/query.ts (1)
  • IdentityResponseSchema (11-19)
apps/dashboard/lib/trpc/trpc.ts (3)
  • t (7-7)
  • requireWorkspace (22-35)
  • withRatelimit (112-127)
apps/dashboard/lib/db.ts (1)
  • db (5-26)
apps/dashboard/lib/trpc/routers/index.ts (1)
apps/dashboard/lib/trpc/routers/identity/search.ts (1)
  • searchIdentities (13-81)
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/general-setup.tsx (1)
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/index.tsx (1)
  • ExternalIdField (18-223)
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/use-search-identities.tsx (1)
apps/dashboard/lib/trpc/server.ts (1)
  • trpc (7-14)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Test Packages / Test ./packages/api
  • GitHub Check: Test Packages / Test ./internal/encryption
  • GitHub Check: Test Packages / Test ./packages/hono
  • GitHub Check: Test Packages / Test ./internal/clickhouse
  • GitHub Check: Test Packages / Test ./packages/cache
  • GitHub Check: Test Packages / Test ./internal/id
  • GitHub Check: autofix
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (9)
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/index.ts (1)

7-7: Default page size reduced – double-check downstream expectations

Dropping the default from 50 → 10 dramatically increases the number of network round-trips during infinite scroll. Please verify that:

  1. UI/UX remains acceptable (scroll jitter, loading spinners, etc.).
  2. Any call-sites that relied on the previous implicit “first 50” behaviour consciously override the new default when necessary.

If a majority of screens still want 50, consider passing the limit explicitly from callers instead of changing the default here.

apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-create-identity.ts (1)

16-18: 👍 Added cache-bust for identity.search

Good catch adding trpcUtils.identity.search.invalidate() so search results reflect the newly created identity without a hard refresh.

apps/dashboard/lib/trpc/routers/index.ts (1)

230-231: Router entry added but permissions unchanged

identity.search is now publicly exposed the same way as identity.query. If query previously required a certain permission scope/rate-limit weight, make sure search is covered identically; otherwise consumers could bypass quota by calling search instead of paginated query.

apps/dashboard/lib/trpc/routers/identity/query.ts (1)

11-19: Schema re-export looks safe

Exporting IdentityResponseSchema improves reuse and typing; no functional changes introduced.

apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-external-id/index.tsx (1)

40-42: Possible backend contract mismatch for keyIds

keyIds is passed as a string but the batch edit hook likely expects string[] (consistent with the multi-selection component). Confirm the mutation signature to avoid runtime validation errors.

- keyIds: keyDetails.id,
+ keyIds: [keyDetails.id],
apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls/components/batch-edit-external-id.tsx (1)

22-22: LGTM! Consistent handling of identityId and externalId

The component correctly manages both selectedIdentityId and selectedExternalId states, properly passing them together in mutation payloads and handling the updated onChange callback signature.

Also applies to: 36-36, 62-62, 147-150

apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/use-search-identities.tsx (1)

1-34: Well-implemented debounced search hook

The hook correctly implements debouncing with proper cleanup, memoizes results to avoid unnecessary recalculations, and provides accurate loading states. The 30-second cache time is reasonable for search results.

apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/index.tsx (2)

25-26: Excellent UX improvements with smooth transitions

The implementation of React transitions and conditional loading states provides a smooth user experience during search operations. The opacity transitions and "Searching..." indicator clearly communicate the loading state to users.

Also applies to: 109-110, 121-124, 134-152


130-131: Proper handling of identity selection

The code correctly finds the identity by ID and safely handles the case where no identity is found, passing null values for both identityId and externalId.

@chronark
Copy link
Collaborator

this one has a ton of rabbit comments and merge conflicts, can you address/close the comments first?

Copy link
Contributor Author

lets go pr by pr. you seen any issues in roles PR except that coderabbit comment?

Copy link
Contributor Author

let's merge this last. i'll check it and test it myself again

@vercel vercel bot temporarily deployed to Preview – dashboard June 19, 2025 13:27 Inactive
@vercel vercel bot temporarily deployed to Preview – engineering June 19, 2025 13:33 Inactive
Copy link
Contributor Author

I found some bugs myself actually, but it should be good to go now

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d7abfde and 24eaadf.

📒 Files selected for processing (3)
  • apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/index.tsx (6 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/index.ts (1 hunks)
  • apps/dashboard/lib/trpc/routers/index.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/index.tsx (1)
Learnt from: ogzhanolguncu
PR: unkeyed/unkey#3315
File: apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/general-setup.tsx:40-50
Timestamp: 2025-06-19T13:01:55.310Z
Learning: In the create-key form's GeneralSetup component, the Controller is intentionally bound to "identityId" as the primary field while "externalId" is set explicitly via setValue. The ExternalIdField component has been designed to handle this pattern where it receives identityId as its value prop but manages both identityId and externalId through its onChange callback.
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Test Packages / Test ./packages/hono
  • GitHub Check: Test Packages / Test ./packages/rbac
  • GitHub Check: Test Packages / Test ./internal/clickhouse
  • GitHub Check: Test Packages / Test ./internal/id
  • GitHub Check: autofix
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
apps/dashboard/lib/trpc/routers/index.ts (1)

39-39: Clean integration of search functionality.

The import and route mapping follow the established patterns in the codebase and properly integrate the new search capability into the identity router.

Also applies to: 272-272

apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/index.ts (1)

7-8: Good optimization for search-enabled workflow.

Reducing the default fetch limit from 50 to 10 makes sense when search functionality is available, as users can find specific identities without loading large pages.

apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/index.tsx (1)

142-142: Well-implemented loading states and UX enhancements.

The loading state management effectively handles both initial loading and search states, providing clear feedback to users. The conditional loading indicators and disabled states create a smooth user experience.

Also applies to: 218-223, 237-246

@vercel vercel bot temporarily deployed to Preview – dashboard June 19, 2025 13:35 Inactive
@mcstepp mcstepp self-assigned this Jun 24, 2025
@vercel vercel bot temporarily deployed to Preview – dashboard June 24, 2025 14:41 Inactive
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (3)
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/index.tsx (3)

42-57: Consider simplifying the data merging logic.

The current logic for combining identities from different sources is complex and could be error-prone. Consider extracting this logic into a custom hook or utility function for better testability and maintainability.


72-83: Avoid creating mock identity objects with placeholder data.

Creating a mock identity with empty strings for workspaceId, environment, and arbitrary timestamps could lead to unexpected behavior or data inconsistency. Consider refactoring to either ensure current identity has all required fields or handle the missing current identity case more explicitly.


240-241: Resolve type safety issue instead of suppressing it.

The @ts-expect-error comment indicates a type mismatch that should be addressed rather than suppressed, especially since it mentions being "fixed in following PRs."

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 24eaadf and 3886b88.

📒 Files selected for processing (1)
  • apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/index.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/index.tsx (1)
Learnt from: ogzhanolguncu
PR: unkeyed/unkey#3315
File: apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/general-setup.tsx:40-50
Timestamp: 2025-06-19T13:01:55.310Z
Learning: In the create-key form's GeneralSetup component, the Controller is intentionally bound to "identityId" as the primary field while "externalId" is set explicitly via setValue. The ExternalIdField component has been designed to handle this pattern where it receives identityId as its value prop but manages both identityId and externalId through its onChange callback.
🔇 Additional comments (1)
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/index.tsx (1)

154-156: Verify the onChange behavior matches expectations.

The onChange handler only updates the search value but doesn't trigger the identity selection. Ensure this is the intended behavior and that selection only happens through the onSelect handler.

Based on the retrieved learning, this pattern is intentional where the Controller is bound to "identityId" while "externalId" is managed separately. However, please verify that this search-only behavior in onChange doesn't interfere with form validation or user expectations.

@ogzhanolguncu ogzhanolguncu changed the title feat: add db search to externalId - Merge after #3312 feat: add db search to externalId Jun 24, 2025
@vercel vercel bot temporarily deployed to Preview – engineering June 24, 2025 17:36 Inactive
Copy link
Collaborator

@mcstepp mcstepp left a comment

Choose a reason for hiding this comment

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

👍

@vercel vercel bot temporarily deployed to Preview – dashboard June 24, 2025 17:40 Inactive
@ogzhanolguncu ogzhanolguncu enabled auto-merge June 24, 2025 17:43
@ogzhanolguncu ogzhanolguncu force-pushed the add-db-search-to-externalid branch from 29f7520 to 72a3298 Compare June 24, 2025 17:49
@ogzhanolguncu ogzhanolguncu requested a review from mcstepp June 24, 2025 17:53
@vercel vercel bot temporarily deployed to Preview – engineering June 24, 2025 17:53 Inactive
@vercel vercel bot temporarily deployed to Preview – dashboard June 24, 2025 17:55 Inactive
@ogzhanolguncu
Copy link
Contributor Author

@mcstepp can you approve again? I had to fix the build issue

Copy link
Collaborator

@mcstepp mcstepp left a comment

Choose a reason for hiding this comment

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

👍

@ogzhanolguncu ogzhanolguncu added this pull request to the merge queue Jun 24, 2025
Merged via the queue into main with commit c4ca81b Jun 24, 2025
31 checks passed
@ogzhanolguncu ogzhanolguncu deleted the add-db-search-to-externalid branch June 24, 2025 18:06
@coderabbitai coderabbitai bot mentioned this pull request Jul 15, 2025
18 tasks
@coderabbitai coderabbitai bot mentioned this pull request Sep 24, 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.

3 participants