POST /api/v1/snapshots/import hands back a 500 for a few ordinary payloads, and the response carries the raw Node error text.
uploadSnapshot in forge/db/controllers/Snapshot.js reads the incoming env unguarded:
const keys = Object.keys(snapshot.settings.env)
keys.forEach((key) => {
const env = snapshot.settings.env[key]
if (env.hidden && env.$) {
env.value = decryptValue(credentialSecret, env.$)
Three ways that blows up, all reproduced against a local platform:
- no
settings.env at all (the route's own body schema doesn't require it), 500 Cannot convert undefined or null to object
- an env value of
null, 500 on env.hidden
- a snapshot with encrypted hidden env values and no
credentialSecret, 500 The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
The third one also happens when the env vars are being thrown away anyway (components.envVars: false or "keys"), because the decrypt loop runs over the original snapshot before the component filtering is applied.
The raw messages go straight to the caller, which isn't great for a public endpoint.
Might be worth defaulting env to {}, skipping values that aren't objects, and returning a 400 when a secret is genuinely needed but missing.
POST /api/v1/snapshots/importhands back a 500 for a few ordinary payloads, and the response carries the raw Node error text.uploadSnapshotinforge/db/controllers/Snapshot.jsreads the incoming env unguarded:Three ways that blows up, all reproduced against a local platform:
settings.envat all (the route's own body schema doesn't require it),500 Cannot convert undefined or null to objectnull, 500 onenv.hiddencredentialSecret,500 The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefinedThe third one also happens when the env vars are being thrown away anyway (
components.envVars: falseor"keys"), because the decrypt loop runs over the original snapshot before the component filtering is applied.The raw messages go straight to the caller, which isn't great for a public endpoint.
Might be worth defaulting env to
{}, skipping values that aren't objects, and returning a 400 when a secret is genuinely needed but missing.