Skip to content

Commit 4ebaae0

Browse files
fix(api): use js-yaml named imports for v5 compatibility
js-yaml v5 is ESM-only and dropped its default export, exposing only flat named exports. The profile export route imported the default (`import yaml from 'js-yaml'`), so `yaml.dump()` threw and the export endpoint returned 500. Switch to named imports (`dump`/`load`) in the route and its test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 1a44062 commit 4ebaae0

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/routes/admin/profiles/export.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { exportProfile } from './export.js'
88
import { Environment } from '../../../utils/Environment.js'
99

1010
import { vi, type MockInstance } from 'vitest'
11-
import yaml from 'js-yaml'
11+
import { load } from 'js-yaml'
1212
import crypto from 'crypto'
1313

1414
describe('Profiles - Export', () => {
@@ -41,7 +41,7 @@ describe('Profiles - Export', () => {
4141
decipher.setAuthTag(tag)
4242
const decrypted = Buffer.concat([decipher.update(ct), decipher.final()])
4343
const pt = decrypted.toString('utf8')
44-
return yaml.load(pt)
44+
return load(pt)
4545
}
4646

4747
beforeEach(() => {

src/routes/admin/profiles/export.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { NOT_FOUND_EXCEPTION, NOT_FOUND_MESSAGE } from '../../../utils/constants
55
import handleError from '../../../utils/handleError.js'
66
import { RPSError } from '../../../utils/RPSError.js'
77
import { type Request, type Response } from 'express'
8-
import yaml from 'js-yaml'
8+
import { dump } from 'js-yaml'
99
import { encryptWithRandomKey } from '../../../utils/encryptWithRandomKey.js'
1010
import { type CertCredentials } from '../../../interfaces/ISecretManagerService.js'
1111
import { Environment } from '../../../utils/Environment.js'
@@ -203,7 +203,7 @@ export async function exportProfile(req: Request, res: Response): Promise<void>
203203
}
204204
}
205205

206-
const yamlStr = yaml.dump(output)
206+
const yamlStr = dump(output)
207207
// Encrypt the YAML string and provide the key
208208
const { cipherText, key } = encryptWithRandomKey(yamlStr)
209209

0 commit comments

Comments
 (0)