From 4bed030d40ad9f0d7e6ab612a7433f528c864f81 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 26 Jul 2019 14:50:58 -0700 Subject: [PATCH] don't validate MinItems with unknowns in a block If there are unknowns, the block may have come from a dynamic declaration, and we can't validate MinItems. Once the blocks are expanded, we will get the full config for validation without any unknown values. --- helper/schema/schema.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/helper/schema/schema.go b/helper/schema/schema.go index 9316229631..5f16672d35 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -1456,6 +1456,15 @@ func (m schemaMap) validateList( "%s: should be a list", k)} } + // We can't validate list length if this came from a dynamic block. + // Since there's no way to determine if something was from a dynamic block + // at this point, we're going to skip validation in the new protocol if + // there are any unknowns. Validate will eventually be called again once + // all values are known. + if isProto5() && !isWhollyKnown(raw) { + return nil, nil + } + // Validate length if schema.MaxItems > 0 && rawV.Len() > schema.MaxItems { return nil, []error{fmt.Errorf(