Skip to content

Commit 4a1c8f2

Browse files
Copiloteoinsha
andauthored
fix: fail fast when CDK_OUTDIR is unset in PythonFunction metadata
Agent-Logs-Url: https://github.com/fourTheorem/uv-python-lambda/sessions/2c145af7-fdbc-4b71-bebc-332000b25ef0 Co-authored-by: eoinsha <868390+eoinsha@users.noreply.github.com>
1 parent cf6c7d3 commit 4a1c8f2

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/function.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,18 @@ export class PythonFunction extends Function {
9595
code,
9696
handler: resolvedHandler,
9797
});
98-
const assetRelPath = path.relative(process.env.CDK_OUTDIR ?? '', code.path);
98+
const assetRelPath = path.relative(getCdkOutDir(), code.path);
9999
(this.node.defaultChild as CfnFunction).addMetadata(
100100
'uv-python-lambda:asset-path',
101101
assetRelPath,
102102
);
103103
}
104104
}
105+
106+
function getCdkOutDir() {
107+
const cdkOutDir = process.env.CDK_OUTDIR;
108+
if (!cdkOutDir) {
109+
throw new Error('CDK_OUTDIR must be set before bundling Lambda assets');
110+
}
111+
return path.resolve(cdkOutDir);
112+
}

0 commit comments

Comments
 (0)