I finally registered here to upvote your question, but I didn't have this ability due to reputations limitation (as well as comment), that's why I'll try to provide somewhat useful answer.
According to my digging in documentation UndefinedVar is Build Check.
According to docs:
Build checks are supported in: Buildx version 0.15.0 and later
According to changelog:
0.15.0 2024-06-11 The full release note for this release is available on GitHub.
New
--calloption allows setting evaluation method for a build, replacing the previous experimentalIn addition to the default build method, the following methods are implemented by Dockerfile frontend:
--call=check: Run validation routines for your build configuration. For more information about build checks, see Build checks
So this is a relatively new addition and doesn't have a lot of feedback.
Of course, you can turn it off with check=skip skip-checks
But I cannot find proper way about fixing it neither in docs nor here and related (old) question doesn't have these problems. I've created my own issue.
In our case, we are using PYTHONPATH variable:
PYTHONPATH="$SOFT/Stranger-${STRANGER_VERSION}/local/lib/python3.10/dist-packages:$PYTHONPATH"
And we got same warning: UndefinedVar: Usage of undefined variable '$PYTHONPATH' (line 72)
I've tried
PYTHONPATH="$SOFT/Stranger-${STRANGER_VERSION}/local/lib/python3.10/dist-packages:${PYTHONPATH:-''}"
Doesn't help.