Skip to content

🐛Fix "literal not terminated" error for markers with unpaired backticks in Pattern #1376

Open
dongjiang1989 wants to merge 1 commit intokubernetes-sigs:mainfrom
dongjiang1989:update-pattern
Open

🐛Fix "literal not terminated" error for markers with unpaired backticks in Pattern #1376
dongjiang1989 wants to merge 1 commit intokubernetes-sigs:mainfrom
dongjiang1989:update-pattern

Conversation

@dongjiang1989
Copy link
Copy Markdown
Member

Summary

Fixes the scanner error "literal not terminated" when parsing markers that contain an unpaired backtick in their pattern values, such as:

  // +kubebuilder:validation:items:Pattern=^[`a-zA-Z]+$                                                                                                      

Closes: #1084

Changes

  1. pkg/markers/parse.go - Modified parserScanner function to:
    - Only enable ScanRawStrings when the input contains an even (balanced) number of backticks
    - Fix type conversion: scanner.Mode = uint(mode) to resolve compilation error
  2. pkg/markers/parse_internal_test.go ( add new file) - Added test cases covering:
    - Single backtick pattern
    - Full "+kubebuilder:validation:items:Pattern=^[a-zA-Z]+$`" marker
    - Two backticks (balanced)
    - Three backticks (unbalanced)
    - Empty string (zero backticks)

Signed-off-by: dongjiang <[email protected]>
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dongjiang1989
Once this PR has been reviewed and has the lgtm label, please assign joelspeed for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 9, 2026
@dongjiang1989 dongjiang1989 changed the title Fix "literal not terminated" error for markers with unpaired backticks in Pattern 🐛Fix "literal not terminated" error for markers with unpaired backticks in Pattern Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generating manifest with backtick in pattern

2 participants