Doug DeBold
10/01/2025, 4:57 PM$deploy function from the UI and it's returning "Invalid Reference".
I think the issue is coming from how the executableCode value is stored. Looking at my bot in the UI and what is stored in the DB, I see this:
"executableCode": { "contentType": "text/typescript", "url": "https://medplum-storage.mydomain.com/signedcloudfronturl", "title": "index.js" } }
but looking at the deploy.test.js the bot is being created with executableCode: { url: Binary/${binary.id} }, see https://github.com/medplum/medplum/blob/main/packages/server/src/fhir/operations/deploy.test.ts#L99
Given this difference it's pretty clear that when we call
const binary = await repo.readReference<Binary>({
reference: (bot.executableCode as Attachment).url as string,
});
it will fail. I'm running on server version 4.4.1. Any advice on how to fix this?Doug DeBold
10/01/2025, 5:06 PMsimonj
10/01/2025, 6:05 PMmedplum-storage.mydomain.com it's not copy/pasted verbatim from the bot JSON right?Doug DeBold
10/01/2025, 6:55 PM"url" path opens up the .js file being served through cloudfront, and I have the following ENV vars setup:
{
"name": "MEDPLUM_BOT_LAMBDA_ROLE_ARN",
"value": "arn:aws:iam::my-role"
},
{ "name": "MEDPLUM_BOT_LAMBDA_LAYER_NAME", "value": "medplum-bot-layer" },
{ "name": "MEDPLUM_VM_CONTEXT_BOTS_ENABLED", "value": "false" },
{ "name": "MEDPLUM_DEFAULT_BOT_RUNTIME_VERSION", "value": "awslambda" }
Although this is making me think to double check the lambda role is correct. Yesterday I dealt with a completely obscure error when uploading that turned out to be a lack of S3 permissions b/c I assigned them to my EC2 role instead of my ECS Task RoleDoug DeBold
10/01/2025, 7:05 PMGetObject from my s3 storage bucket and ListLayerVersions so it seems unlikely that this is a permissions issue.
Looking at my staging ENV which is deployed to EC2 via docker-compose, it also has this same structure for the bots in the executableCode and is working... I don't understand how this works in the first placeMaddy
10/01/2025, 9:19 PM{
"contentType": "text/typescript",
"url": "Binary/{binary-id}"
}Doug DeBold
10/01/2025, 9:20 PMexecutableCode is being stored the exact same as I'm seeing it in the UIMaddy
10/01/2025, 9:22 PMDoug DeBold
10/01/2025, 9:30 PMDoug DeBold
10/01/2025, 9:31 PMDoug DeBold
10/01/2025, 9:35 PMurl: "Binary/:id" syntax in the database... which explains why that is working.
But my production deployment is storing the literal response from the creation of the fileDoug DeBold
10/01/2025, 9:39 PM{ op: 'add', path: '/executableCode', value: { contentType: 'text/typescript', url: 'https://..', title: 'index.js }Doug DeBold
10/01/2025, 9:41 PMurl: 'Binary/:id' while in 4.4.1 it's notMaddy
10/01/2025, 10:48 PMimport { MedplumClient } from '@medplum/core';
const medplum = new MedplumClient();
// Deploy bot using the $deploy operation
const deployResult = await medplum.post(
medplum.fhirUrl('Bot', botId, '$deploy'),
{
code: botCode,
filename: 'index.js'
}
);Doug DeBold
10/01/2025, 10:57 PMMaddy
10/02/2025, 4:35 PMDoug DeBold
10/02/2025, 5:48 PM