Skip to content

fix(ui-react): use plain strings for public key filter tags#6128

Merged
gustavosbarreto merged 3 commits intomasterfrom
fix/public-key-filter-string-tags
Apr 7, 2026
Merged

fix(ui-react): use plain strings for public key filter tags#6128
gustavosbarreto merged 3 commits intomasterfrom
fix/public-key-filter-string-tags

Conversation

@luannmoreira
Copy link
Copy Markdown
Member

What

Corrected the public key filter tags to use plain string[] instead of Tag[] objects throughout the create/update flow and the response normalization.

Why

The OpenAPI spec incorrectly referenced tag.yaml for filter.tags items, which typed them as full Tag objects. The server accepts and returns plain strings. The frontend had accumulated a workaround: normalizePublicKey mapped { name } objects back to strings on read, and buildFilter mapped strings to { name } objects on write. Fixing the spec removes the need for both workarounds.

Changes

  • publicKeyFilter.yaml: replaced $ref: tag.yaml with an inline string type (minLength: 3, maxLength: 255) to match what the server actually accepts and returns
  • usePublicKeys.ts: removed the { name } unwrapping in normalizePublicKey — tags from the response are now passed through as-is
  • KeyDrawer.tsx: removed the { name } wrapping in buildFilter and the now-unused Tag import — selectedTags (already string[]) is sent directly
  • tests: added usePublicKeys.test.ts (13 tests) and KeyDrawer.test.tsx (28 tests) covering normalization, filter initialization from editKey, and the corrected buildFilter output for all three filter modes

@luannmoreira luannmoreira requested review from a team as code owners April 7, 2026 15:13
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

Claude finished @luannmoreira's task in 3m 51s —— View job


Code Review Complete

Reviewed 5 files across code quality, security, testing, language patterns, and architecture — no issues found. The code looks good as-is.

The spec fix correctly aligns publicKeyFilter.yaml with the Go backend (which already uses []string for tags in pkg/api/requests/publickey.go and pkg/api/responses/publickey.go), and the frontend simplifications in normalizePublicKey and buildFilter cleanly remove the now-unnecessary object wrapping/unwrapping. The new tests (41 total) provide solid coverage of the changed behavior.


If you push additional changes and want a new review, tag @shellhub-io/admin and a team member can trigger it.

@luannmoreira luannmoreira self-assigned this Apr 7, 2026
@luannmoreira luannmoreira force-pushed the fix/public-key-filter-string-tags branch 3 times, most recently from 62667f5 to 600cc53 Compare April 7, 2026 15:25
The tags items in publicKeyFilter were referencing tag.yaml, typing
them as full Tag objects. The server accepts and returns plain strings,
so replace the $ref with an inline string type carrying the same
constraints (minLength: 3, maxLength: 255).
normalizePublicKey was mapping Tag objects to strings on read, and
buildFilter was wrapping strings back into { name } objects on write,
working around the incorrect spec. With the spec corrected, pass
filter.tags through as-is in both directions and drop the Tag import.
Add usePublicKeys hook tests covering normalizePublicKey for both
hostname and tags filter variants, and KeyDrawer tests covering filter
initialization from editKey, buildFilter output for all three filter
modes, and the create/update flows.
@luannmoreira luannmoreira force-pushed the fix/public-key-filter-string-tags branch from 600cc53 to 4bb9b2b Compare April 7, 2026 15:30
@gustavosbarreto gustavosbarreto merged commit 40ba708 into master Apr 7, 2026
13 checks passed
@gustavosbarreto gustavosbarreto deleted the fix/public-key-filter-string-tags branch April 7, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants