Fix panic in validate context for build

Fixes #7611

Signed-off-by: Michael Crosby <michael@docker.com>
Merge pull request #7615 from crosbymichael/fix-utils-panic

Fix panic in validate context for build