Skip to content

Commit c3d1db5

Browse files
[Internal] Escape single quotes in regex matchers (#727)
## Changes This PR makes sure that single quotes are properly escaped when passing regex pattern to match errors. ## Tests Verified that SDK can properly be generated when the pattern contains single quotes. Note that `downstreams / compatibility (ucx, databrickslabs)` was already failing and that this PR should not affect downstream consumers. - [x] `make test` run locally - [x] `make fmt` applied - [x] relevant integration tests applied
1 parent c2cc3ea commit c3d1db5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

.codegen/error_overrides.py.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ _ALL_OVERRIDES = [
1111
debug_name="{{.Name}}",
1212
path_regex=re.compile(r'{{.PathRegex}}'),
1313
verb="{{.Verb}}",
14-
status_code_matcher=re.compile(r'{{.StatusCodeMatcher}}'),
15-
error_code_matcher=re.compile(r'{{.ErrorCodeMatcher}}'),
16-
message_matcher=re.compile(r'{{.MessageMatcher}}'),
14+
status_code_matcher=re.compile(r'{{replaceAll "'" "\\'" .StatusCodeMatcher}}'),
15+
error_code_matcher=re.compile(r'{{replaceAll "'" "\\'" .ErrorCodeMatcher}}'),
16+
message_matcher=re.compile(r'{{replaceAll "'" "\\'" .MessageMatcher}}'),
1717
custom_error={{.OverrideErrorCode.PascalName}},
1818
),
1919
{{- end }}

0 commit comments

Comments
 (0)