Thanks for taking a look. I tried some more things and it looks like it's a misleading compiler error, maybe nothing to do with the path variable at all even though the compiler says it is.
I took the path variable out of the function temporarily, then it gave another error: "Task or actor isolated value cannot be sent; this is an error in the Swift 6 language mode".
The containing class is marked as @Observable, so I'm assuming really it is complaining that "self" is getting pulled into the Task which can cause race conditions even though the compiler error does not say that. I added the Sendable protocol to the container class and the warning went away.
Thanks for taking the time to look into it.
Side note: Swift6 makes writing code miserable, it's so broken still, good idea poor execution.