Problem
When a user uploads an SSH public key that is already enrolled as an SSH Identity, the backend returns HTTP 200 with the existing record unchanged. The frontend receives no signal that the key was not actually created, so the user sees no feedback — no error, no toast, no indication that the operation was a no-op.
This happens because enrollSSHIdentity in server/api/services/ssh-identity.go treats same-fingerprint-same-user as an idempotent success (lines 126–128), returning the existing *models.SSHIdentity with a nil error. The route handler then responds with 200 and the old record, which is indistinguishable from a successful creation.
For comparison, the legacy Public Keys endpoint (CreatePublicKey in server/api/services/sshkeys.go) returns ErrPublicKeyDuplicated (→ HTTP 409) when the fingerprint already exists, giving the frontend a clear signal to display an error.
Expected behavior
The user should see a clear message (e.g. "This key is already enrolled") when they attempt to add a key that already exists.
Suggested fix
Return a 409 Conflict (or a dedicated error like ErrSSHIdentityAlreadyEnrolled) when the fingerprint belongs to the same user, instead of silently returning the existing record. This aligns with how CreatePublicKey handles duplicates and gives the frontend the error it needs to display a meaningful message.
Problem
When a user uploads an SSH public key that is already enrolled as an SSH Identity, the backend returns HTTP 200 with the existing record unchanged. The frontend receives no signal that the key was not actually created, so the user sees no feedback — no error, no toast, no indication that the operation was a no-op.
This happens because
enrollSSHIdentityinserver/api/services/ssh-identity.gotreats same-fingerprint-same-user as an idempotent success (lines 126–128), returning the existing*models.SSHIdentitywith anilerror. The route handler then responds with 200 and the old record, which is indistinguishable from a successful creation.For comparison, the legacy Public Keys endpoint (
CreatePublicKeyinserver/api/services/sshkeys.go) returnsErrPublicKeyDuplicated(→ HTTP 409) when the fingerprint already exists, giving the frontend a clear signal to display an error.Expected behavior
The user should see a clear message (e.g. "This key is already enrolled") when they attempt to add a key that already exists.
Suggested fix
Return a
409 Conflict(or a dedicated error likeErrSSHIdentityAlreadyEnrolled) when the fingerprint belongs to the same user, instead of silently returning the existing record. This aligns with howCreatePublicKeyhandles duplicates and gives the frontend the error it needs to display a meaningful message.