Skip to content

Commit 7e0b21f

Browse files
committed
fix: sync handle on user ensure (#293) (thanks @christianhpoe)
1 parent 71c6705 commit 7e0b21f

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Fixed
6+
- Users: sync handle on ensure when GitHub login changes (#293) (thanks @christianhpoe).
7+
38
## 0.6.1 - 2026-02-13
49

510
### Added

convex/users.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { afterEach, describe, expect, it, vi } from 'vitest'
22

3-
vi.mock('./lib/access', () => ({
4-
requireUser: vi.fn(),
5-
}))
3+
vi.mock('./lib/access', async () => {
4+
const actual = await vi.importActual<typeof import('./lib/access')>('./lib/access')
5+
return { ...actual, requireUser: vi.fn() }
6+
})
67

78
const { requireUser } = await import('./lib/access')
89
const { ensureHandler } = await import('./users')

convex/users.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ export async function ensureHandler(ctx: MutationCtx) {
8484
const existingHandle = user.handle?.trim() || undefined
8585
const nameHandle = user.name?.trim() || undefined
8686
const emailHandle = user.email?.split('@')[0]?.trim() || undefined
87-
const derivedHandle = nameHandle || emailHandle
87+
// `user.name` is the GitHub login (see convex/auth.ts profile mapping).
88+
// Only fall back to deriving from email if we don't already have a handle.
89+
const derivedHandle = nameHandle || (!existingHandle ? emailHandle : undefined)
8890
const baseHandle = derivedHandle ?? existingHandle
8991

9092
if (derivedHandle && (!existingHandle || existingHandle !== derivedHandle)) {

packages/clawdhub/src/skills.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ import {
2020

2121
describe('skills', () => {
2222
it('extracts zip into directory and skips traversal', async () => {
23-
const dir = await mkdtemp(join(tmpdir(), 'clawhub-'))
23+
const parent = await mkdtemp(join(tmpdir(), 'clawhub-zip-'))
24+
const dir = join(parent, 'dir')
25+
await mkdir(dir)
26+
const evilName = `evil-${parent.split('/').pop() ?? 'file'}.txt`
2427
const zip = zipSync({
2528
'SKILL.md': strToU8('hello'),
26-
'../evil.txt': strToU8('nope'),
29+
[`../${evilName}`]: strToU8('nope'),
2730
})
2831
await extractZipToDir(new Uint8Array(zip), dir)
2932

3033
expect((await readFile(join(dir, 'SKILL.md'), 'utf8')).trim()).toBe('hello')
31-
await expect(stat(join(dir, '..', 'evil.txt'))).rejects.toBeTruthy()
34+
await expect(stat(join(parent, evilName))).rejects.toBeTruthy()
3235
})
3336

3437
it('writes and reads lockfile', async () => {

0 commit comments

Comments
 (0)