Help: Migration v31 Stuck & Failing
# support
d
🚨 Help: Migration v31 Stuck After Major Upgrade Hey @everyone, we're blocked. We just completed a major upgrade from 4.3.6 to 5.0.0 (following all the required intermediate bumps), but now our post-deploy migration v31 (rebuildR4ValueSets) is completely stuck and failing repeatedly. 🔴 Symptom: 10+ failed attempts for v31 in the AsyncJob Dashboard. 🔴 Suspicion: We're seeing constant Validator warning: Invalid reference: got "Bot" logs. We think the migration is validating existing AuditEvents, finding these invalid Bot references, and failing. This is blocking our 5.0.0 upgrade from completing. Has anyone hit this? What's the best way to get the migration unstuck? Can we skip validation or clean the data first? https://cdn.discordapp.com/attachments/1435933404507144234/1435933404762869774/Screenshot_from_2025-11-06_15-16-05.png?ex=69412f32&is=693fddb2&hm=b798d27fd7000ce8dcf3893492cd443d65dd47c84567865126a86f212a36ea1a&
r
Sorry about the inconvenience @DevOps Demon . If click on the blue link under "AsyncJob" and and look in the "JSON" tab, what do you see? Any error messages
c
Hi @DevOps Demon - Apologies for the noisy Bot validation warnings. Those are non-blockers. We are working on cleaning those up, but those are unrelated to the failed migration. Do you see any other notable migration server logs? The v31 post-deploy migration was relatively minor (it was a fix to some CodeSystem URLs, so definitely not something to panic about). The v31 post-deploy migration is safe to skip. If you want to do that just to move forward, you can use one of these options: Option 1: Direct Database Update
Copy code
-- Run this SQL query on your Postgres database
UPDATE "DatabaseMigration" SET "dataVersion"=31;
Option 2: API Command In version 3.3.0, we also added an API endpoint to set the data version. You can use this endpoint to set the data version to 1.
Copy code
# Get an auth token
export AUTH_TOKEN=$(npx medplum token)

# Use curl to set the data version
curl -X POST \
  -H "Authorization: Bearer $AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  https://api.medplum.com/admin/super/setdataversion \
  -d '{ "dataVersion": 31 }'
After using either option, you can proceed directly to upgrading to version 5.0.0.
d
Hi @rahul1 i will add a screenshot of those logs if needed but for context we are getting warnings and errors related to either value Set, structure definitions and bots out which as @cody said bot one is known warning. Give me some time i’ll get back with screenshots or logs.
Thanks @cody for confirming that bot validation issue is not something to worry about. As i said above we are facing some other issues as well let me add those issues here related mostly to valueSets and structureDefinitions
Bot Error: "Dynamic require of "@medplum/core" is not supported" We are experiencing a runtime error in our Medplum Bots when we import certain utilities from @medplum/core. The Issue: When a Bot's code includes an import for functions like resolveId or getUserDisplay, any attempt to execute the Bot fails with a 400 Bad Request. The OperationOutcome in the response is: JSON { "severity": "error", "code": "invalid", "details": { "text": "Dynamic require of \"@medplum/core\" is not supported" } }Code Causing the Error: This error occurs when our Bot file includes an import for a function (a value) like resolveId: TypeScript import { BotEvent, MedplumClient, resolveId } from '@medplum/core'; import { Appointment } from '@medplum/fhirtypes'; export async function handler(medplum: MedplumClient, event: BotEvent): Promise { // ... const slotId = resolveId(event.input.slot?.[0]); // ... return event.input; }Observation: We've noticed that Bots without these specific utility imports (e.g., Bots that only import types like BotEvent) execute correctly. The error seems to be triggered specifically by importing runtime values from @medplum/core. Could you please let us know the correct way to use functions like resolveId within a Bot? Thank you. https://cdn.discordapp.com/attachments/1435933404507144234/1436244240886665226/Screenshot_2025-11-07_at_12.00.42_PM.png?ex=690ee62f&is=690d94af&hm=3402a2153218493c0b5f6b2643f7a6731ada7e005cfb4e18fb804f7109c294c4& https://cdn.discordapp.com/attachments/1435933404507144234/1436244241167814698/Screenshot_2025-11-07_at_11.59.52_AM.png?ex=690ee62f&is=690d94af&hm=b709888acb0046b32fc759237443e5d1d5b3acc56289fd50250b5e0eed2a491f&
c
Hi @DevOps Demon - a few clarifying questions: 1. I assume both
app
and
server
are running Medplum version 5.0.0? You can confirm the
app
version in the top-right menu. You can confirm the
server
version using the
/healthchecek
endpoint 2. Is your bot using runtime version
vmcontext
or
awslambda
? 3. If using
awslambda
, have you recently deployed the Medplum bot lambda layer? https://www.medplum.com/docs/bots/bot-lambda-layer
d
@cody for app and server version both are at 5.0.0. Second thing we are using
Copy code
VMCONTEXT
and our infrastructure is set up on GCP not AWS. So awslambdalayer is out of picture.
i
@DevOps Demon , following up here. Were you able to get past this issue?
d
I have posted same issue in new thread in detailed manner
a
Hello, I'm running into this same issue on my deployment, were you able to find a work around for this? We're also using VMContext for bots.
n
Edit: Deleted a previous message as I'm not confident enough it was accurate. There [has been recent work](https://github.com/medplum/medplum/pull/7718) around this though
a
I'll look into this, thank you for the information!
d
@AceOfSpades please follow the other thread that I shared main issue was solved in that. It is regarding FHIR R4 project not present in projects.
107 Views