Fix panic in validate context for build

Fixes #7611

Signed-off-by: Michael Crosby <michael@docker.com>
I don't want to change this in this PR