Skip to content

query: introduce new ExpectTotalLengthForMatching query check#607

Merged
stephybun merged 7 commits intomainfrom
f/regex-expect-length
Mar 23, 2026
Merged

query: introduce new ExpectTotalLengthForMatching query check#607
stephybun merged 7 commits intomainfrom
f/regex-expect-length

Conversation

@stephybun
Copy link
Copy Markdown
Contributor

@stephybun stephybun commented Feb 11, 2026

Related Issue

Related to #597

Description

  • Introduces the query check ExpectTotalLengthForMatching for validating the number of found resources of multiple list blocks
  • Applies a fix to the ExpectLengthAtLeast check

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
None

@stephybun stephybun requested a review from a team as a code owner February 11, 2026 09:29
// produced by multiple list blocks is exactly the given value.
//
// This query check can only be used with managed resources that support query. Query is only supported in Terraform v1.14+
func ExpectLengthForMultiple(regex *regexp.Regexp, length int) QueryResultCheck {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not attached to this name and open to other suggestions, this just seems the most descriptive at first glance to me.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, tough naming 🤔

Two things I think would be nice to communicate with the name are that it's checking total length and that it's checking via a form of matching resource addresses via regex. What do you think of ExpectTotalLengthForMatching? ExpectTotalLengthForMultiple? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with ExpectTotalLengthForMatching

Copy link
Copy Markdown
Member

@austinvalle austinvalle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! I left some thoughts

Comment thread querycheck/expect_result_length_exact_for_multiple.go Outdated
// produced by multiple list blocks is exactly the given value.
//
// This query check can only be used with managed resources that support query. Query is only supported in Terraform v1.14+
func ExpectLengthForMultiple(regex *regexp.Regexp, length int) QueryResultCheck {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, tough naming 🤔

Two things I think would be nice to communicate with the name are that it's checking total length and that it's checking via a form of matching resource addresses via regex. What do you think of ExpectTotalLengthForMatching? ExpectTotalLengthForMultiple? 🤔

Comment thread querycheck/expect_result_length_exact_for_multiple.go Outdated
Comment thread querycheck/expect_result_length_exact_for_multiple.go Outdated
@stephybun stephybun force-pushed the f/regex-expect-length branch from 88908bf to 273cddb Compare February 17, 2026 07:20
@stephybun
Copy link
Copy Markdown
Contributor Author

Failing CI is unrelated to this change

@stephybun stephybun enabled auto-merge (squash) February 17, 2026 07:41
@austinvalle austinvalle changed the title query: introduce new ExpectLengthForMultiple query check query: introduce new ExpectTotalLengthForMatching query check Feb 23, 2026
Comment thread .changes/unreleased/FEATURES-20260211-122845.yaml Outdated
@stephybun stephybun force-pushed the f/regex-expect-length branch from d057ae1 to e20a4a6 Compare March 23, 2026 09:03
@stephybun stephybun merged commit c5d6ddd into main Mar 23, 2026
46 checks passed
@stephybun stephybun deleted the f/regex-expect-length branch March 23, 2026 13:27
@SBGoods SBGoods added this to the v1.16.0 milestone Apr 8, 2026
@SBGoods SBGoods added the enhancement New feature or request label Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants