Skip to content

Updated .NET regular expressions to use \z instead of $#9026

Merged
glen-84 merged 2 commits intomainfrom
gai/regex-end-of-string
Feb 8, 2026
Merged

Updated .NET regular expressions to use \z instead of $#9026
glen-84 merged 2 commits intomainfrom
gai/regex-end-of-string

Conversation

@glen-84
Copy link
Copy Markdown
Member

@glen-84 glen-84 commented Dec 30, 2025

Summary of the changes (Less than 80 chars)

  • Updated .NET regular expressions to use \z instead of $.

Merge after #8931.

@glen-84 glen-84 marked this pull request as draft December 30, 2025 13:34
@github-actions
Copy link
Copy Markdown
Contributor

🚀 Fusion Gateway Performance Results

Simple Composite Query

Constant Load (50 VUs)

Requests/sec Error Rate
5957.23 req/s 0.00%
📊 Response Time Metrics
Min Med Max Avg P90 P95
0.78ms 6.98ms 160.15ms 8.25ms 12.64ms 18.18ms

Ramping Load (0→50→500→50 VUs)

Requests/sec Error Rate
4600.72 req/s 0.00%
📊 Response Time Metrics
Min Med Max Avg P90 P95
0.78ms 37.66ms 232.19ms 48.26ms 109.30ms 127.20ms

Executed Query

fragment User on User {
  id
  username
  name
}

fragment Review on Review {
  id
  body
}

fragment Product on Product {
  inStock
  name
  price
  shippingEstimate
  upc
  weight
}

query TestQuery {
  topProducts(first: 5) {
    ...Product
    reviews {
      ...Review
      author {
        ...User
      }
    }
  }
}

Deep Recursion Query

Constant Load (50 VUs)

Requests/sec Error Rate
271.64 req/s 0.00%
📊 Response Time Metrics
Min Med Max Avg P90 P95
13.21ms 173.02ms 602.48ms 178.47ms 226.23ms 249.42ms

Ramping Load (0→50→500→50 VUs)

Requests/sec Error Rate
305.49 req/s 0.00%
📊 Response Time Metrics
Min Med Max Avg P90 P95
3.05ms 659.59ms 1692.77ms 688.73ms 1381.25ms 1468.43ms

Executed Query

fragment User on User {
  id
  username
  name
}

fragment Review on Review {
  id
  body
}

fragment Product on Product {
  inStock
  name
  price
  shippingEstimate
  upc
  weight
}

query TestQuery {
  users {
    ...User
    reviews {
      ...Review
      product {
        ...Product
        reviews {
          ...Review
          author {
            ...User
            reviews {
              ...Review
              product {
                ...Product
              }
            }
          }
        }
      }
    }
  }
  topProducts(first: 5) {
    ...Product
    reviews {
      ...Review
      author {
        ...User
        reviews {
          ...Review
          product {
            ...Product
          }
        }
      }
    }
  }
}

Variable Batching Throughput

Constant Load (50 VUs)

Requests/sec Error Rate
23867.17 req/s 0.00%
📊 Response Time Metrics
Min Med Max Avg P90 P95
0.09ms 1.69ms 49.33ms 2.04ms 3.89ms 4.76ms

Ramping Load (0→50→500→50 VUs)

Requests/sec Error Rate
18718.24 req/s 0.00%
📊 Response Time Metrics
Min Med Max Avg P90 P95
0.09ms 9.13ms 105.89ms 11.26ms 23.47ms 28.28ms

Executed Query

query TestQuery_8f7a46ce_2(
  $__fusion_1_upc: ID!
  $__fusion_2_price: Long!
  $__fusion_2_weight: Long!
) {
  productByUpc(upc: $__fusion_1_upc) {
    inStock
    shippingEstimate(weight: $__fusion_2_weight, price: $__fusion_2_price)
  }
}

Variables (5 sets batched in single request)

[
  { "__fusion_1_upc": "1", "__fusion_2_price": 899, "__fusion_2_weight": 100 },
  { "__fusion_1_upc": "2", "__fusion_2_price": 1299, "__fusion_2_weight": 1000 },
  { "__fusion_1_upc": "3", "__fusion_2_price": 15, "__fusion_2_weight": 20 },
  { "__fusion_1_upc": "4", "__fusion_2_price": 499, "__fusion_2_weight": 100 },
  { "__fusion_1_upc": "5", "__fusion_2_price": 1299, "__fusion_2_weight": 1000 }
]

No baseline data available for comparison.


Run 20597666729 • Commit c0d4bd3 • Tue, 30 Dec 2025 13:58:42 GMT

@glen-84 glen-84 marked this pull request as ready for review February 8, 2026 15:41
Copilot AI review requested due to automatic review settings February 8, 2026 15:41
@glen-84 glen-84 merged commit 6fa63d0 into main Feb 8, 2026
98 of 120 checks passed
@glen-84 glen-84 deleted the gai/regex-end-of-string branch February 8, 2026 15:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates scalar validation regex patterns in HotChocolate’s .NET implementation to use \z instead of $ for end-of-string anchoring, tightening validation so inputs with trailing newlines don’t match.

Changes:

  • Replaced $ with \z in multiple scalar validation regex patterns.
  • Converted several patterns to verbatim string literals (@"...") to simplify escaping.
  • Updated the RegexTypeTests stub pattern accordingly.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/HotChocolate/Core/test/Types.Scalars.Tests/RegexTypeTests.cs Updates test stub regex pattern to use \z.
src/HotChocolate/Core/src/Types.Scalars/PhoneNumberType.cs Tightens E.164 phone validation by anchoring with \z.
src/HotChocolate/Core/src/Types.Scalars/MacAddressType.cs Tightens MAC address validation end anchor to \z.
src/HotChocolate/Core/src/Types.Scalars/LongitudeType.cs Updates sexagesimal parsing regex to use \z and verbatim strings.
src/HotChocolate/Core/src/Types.Scalars/LatitudeType.cs Updates sexagesimal parsing regex to use \z and verbatim strings.
src/HotChocolate/Core/src/Types.Scalars/IsbnType.cs Updates complex ISBN validation regex to use \z (including lookaheads).
src/HotChocolate/Core/src/Types.Scalars/IPv6Type.cs Replaces final $ anchor with \z in IPv6(+CIDR) validation.
src/HotChocolate/Core/src/Types.Scalars/IPv4Type.cs Replaces final $ anchor with \z and switches to verbatim strings.
src/HotChocolate/Core/src/Types.Scalars/HexColorType.cs Tightens hex color validation end anchor to \z.
src/HotChocolate/Core/src/Types.Scalars/EmailAddressType.cs Tightens email validation end anchor to \z and switches to verbatim strings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

/// Regex that validates the standard E.164 format
/// </summary>
private const string ValidationPattern = "^\\+[1-9][0-9]{2,14}$";
private const string ValidationPattern = @"^\+[1-9][0-9]{2,14}\z";
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

The switch from $ to \z changes matching semantics (values with a trailing newline will no longer match). Consider adding an explicit negative test case (e.g., a valid value plus \n / \r\n) to lock in the intended behavior and prevent regressions.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 8, 2026

🚀 Fusion Gateway Performance Results

Simple Composite Query

Constant Load (50 VUs)

Requests/sec Error Rate
25208.30 req/s 0.00%
📊 Response Time Metrics
Min Med Max Avg P90 P95
0.09ms 1.60ms 45.47ms 1.94ms 3.63ms 4.50ms

Ramping Load (0→50→500→50 VUs)

Requests/sec Error Rate
19585.79 req/s 0.00%
📊 Response Time Metrics
Min Med Max Avg P90 P95
0.09ms 8.42ms 118.12ms 10.70ms 22.52ms 27.35ms

Executed Query

fragment User on User {
  id
  username
  name
}

fragment Review on Review {
  id
  body
}

fragment Product on Product {
  inStock
  name
  price
  shippingEstimate
  upc
  weight
}

query TestQuery {
  topProducts(first: 5) {
    ...Product
    reviews {
      ...Review
      author {
        ...User
      }
    }
  }
}

Deep Recursion Query

Constant Load (50 VUs)

Requests/sec Error Rate
24698.74 req/s 0.00%
📊 Response Time Metrics
Min Med Max Avg P90 P95
0.09ms 1.63ms 45.03ms 1.98ms 3.74ms 4.60ms

Ramping Load (0→50→500→50 VUs)

Requests/sec Error Rate
19218.57 req/s 0.00%
📊 Response Time Metrics
Min Med Max Avg P90 P95
0.09ms 8.68ms 113.35ms 10.96ms 22.92ms 28.01ms

Executed Query

fragment User on User {
  id
  username
  name
}

fragment Review on Review {
  id
  body
}

fragment Product on Product {
  inStock
  name
  price
  shippingEstimate
  upc
  weight
}

query TestQuery {
  users {
    ...User
    reviews {
      ...Review
      product {
        ...Product
        reviews {
          ...Review
          author {
            ...User
            reviews {
              ...Review
              product {
                ...Product
              }
            }
          }
        }
      }
    }
  }
  topProducts(first: 5) {
    ...Product
    reviews {
      ...Review
      author {
        ...User
        reviews {
          ...Review
          product {
            ...Product
          }
        }
      }
    }
  }
}

Variable Batching Throughput

Constant Load (50 VUs)

Requests/sec Error Rate
27849.20 req/s 0.00%
📊 Response Time Metrics
Min Med Max Avg P90 P95
0.08ms 1.44ms 37.83ms 1.75ms 3.30ms 4.05ms

Ramping Load (0→50→500→50 VUs)

Requests/sec Error Rate
22102.77 req/s 0.00%
📊 Response Time Metrics
Min Med Max Avg P90 P95
0.08ms 6.96ms 104.61ms 9.31ms 19.87ms 24.21ms

Executed Query

query TestQuery_8f7a46ce_2(
  $__fusion_1_upc: ID!
  $__fusion_2_price: Long!
  $__fusion_2_weight: Long!
) {
  productByUpc(upc: $__fusion_1_upc) {
    inStock
    shippingEstimate(weight: $__fusion_2_weight, price: $__fusion_2_price)
  }
}

Variables (5 sets batched in single request)

[
  { "__fusion_1_upc": "1", "__fusion_2_price": 899, "__fusion_2_weight": 100 },
  { "__fusion_1_upc": "2", "__fusion_2_price": 1299, "__fusion_2_weight": 1000 },
  { "__fusion_1_upc": "3", "__fusion_2_price": 15, "__fusion_2_weight": 20 },
  { "__fusion_1_upc": "4", "__fusion_2_price": 499, "__fusion_2_weight": 100 },
  { "__fusion_1_upc": "5", "__fusion_2_price": 1299, "__fusion_2_weight": 1000 }
]

No baseline data available for comparison.


Run 21800807056 • Commit 832c269 • Sun, 08 Feb 2026 15:59:53 GMT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants