Skip to content

Commit 5abc39b

Browse files
committed
bug 1910976 - Expand acceptable extra_keys property names to printable ASCII (from dotted.snake_case)
1 parent f31535f commit 5abc39b

File tree

8 files changed

+22
-8
lines changed

8 files changed

+22
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- Fix JS and Ruby server templates to correctly send event extra values as strings ([DENG-4405](https://mozilla-hub.atlassian.net/browse/DENG-4405))
6+
- ENHANCEMENT: Extra keys in `extra_keys:` fields may now contain any printable ASCII characters ([bug 1910976](https://bugzilla.mozilla.org/show_bug.cgi?id=1910976))
67

78
## 14.3.0
89

glean_parser/schemas/metrics.2-0-0.schema.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ definitions:
2828
pattern: "^[a-z_][a-z0-9_]{0,29}(\\.[a-z_][a-z0-9_]{0,29})*$"
2929
maxLength: 40
3030

31+
event_extra_key:
32+
type: string
33+
pattern: "^[ -~]+$"
34+
maxLength: 40
35+
3136
# Prior to version 2.0.0 of the schema, special ping names with underscores
3237
# were also supported.
3338
kebab_case:
@@ -385,7 +390,7 @@ definitions:
385390
Valid when `type`_ is `event`.
386391
type: object
387392
propertyNames:
388-
$ref: "#/definitions/dotted_snake_case"
393+
$ref: "#/definitions/event_extra_key"
389394
additionalProperties:
390395
type: object
391396
properties:

tests/data/all_metrics.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ all_metrics:
9696
source:
9797
description: Source of this event
9898
type: string
99+
extraKeyNOTJUSTdotted.snake:
100+
description: An extra key with an expressive name.
101+
type: boolean
99102

100103
quantity:
101104
<<: *defaults

tests/data/event_key_ordering.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@ event:
2727
bob:
2828
description: "three"
2929
type: string
30+
And1WithExtraCasing:
31+
description: "four"
32+
type: boolean
3033
expires: 2100-01-01

tests/test_javascript.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def test_event_extra_keys_in_correct_order(tmp_path):
283283
with (tmp_path / "event.js").open("r", encoding="utf-8") as fd:
284284
content = fd.read()
285285
content = " ".join(content.split())
286-
assert '["alice", "bob", "charlie"]' in content
286+
assert '["And1WithExtraCasing", "alice", "bob", "charlie"]' in content
287287

288288

289289
def test_arguments_are_generated_in_deterministic_order(tmp_path):
@@ -304,7 +304,7 @@ def test_arguments_are_generated_in_deterministic_order(tmp_path):
304304
with (tmp_path / "event.js").open("r", encoding="utf-8") as fd:
305305
content = fd.read()
306306
content = " ".join(content.split())
307-
expected = 'export const example = new EventMetricType({ category: "event", name: "example", sendInPings: ["events"], lifetime: "ping", disabled: false, }, ["alice", "bob", "charlie"]);' # noqa
307+
expected = 'export const example = new EventMetricType({ category: "event", name: "example", sendInPings: ["events"], lifetime: "ping", disabled: false, }, ["And1WithExtraCasing", "alice", "bob", "charlie"]);' # noqa
308308
assert expected in content
309309

310310

tests/test_kotlin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,12 @@ def test_event_extra_keys_in_correct_order(tmp_path):
365365
content = fd.read()
366366
content = " ".join(content.split())
367367
assert "ExampleExtra(" in content
368+
assert "and1withextracasing:" in content
368369
assert "alice:" in content
369370
assert "bob:" in content
370371
assert "charlie:" in content
371372
assert ": EventExtras" in content
372-
assert 'allowedExtraKeys = listOf("alice", "bob", "charlie")' in content
373+
assert 'allowedExtraKeys = listOf("And1WithExtraCasing", "alice", "bob", "charlie")' in content
373374

374375

375376
def test_arguments_are_generated_in_deterministic_order(tmp_path):
@@ -392,7 +393,7 @@ def test_arguments_are_generated_in_deterministic_order(tmp_path):
392393
with (tmp_path / "Event.kt").open("r", encoding="utf-8") as fd:
393394
content = fd.read()
394395
content = " ".join(content.split())
395-
expected = 'EventMetricType<ExampleExtra> by lazy { // generated from event.example EventMetricType<ExampleExtra>( CommonMetricData( category = "event", name = "example", sendInPings = listOf("events"), lifetime = Lifetime.PING, disabled = false ), allowedExtraKeys = listOf("alice", "bob", "charlie")) } }' # noqa
396+
expected = 'EventMetricType<ExampleExtra> by lazy { // generated from event.example EventMetricType<ExampleExtra>( CommonMetricData( category = "event", name = "example", sendInPings = listOf("events"), lifetime = Lifetime.PING, disabled = false ), allowedExtraKeys = listOf("And1WithExtraCasing", "alice", "bob", "charlie")) } }' # noqa
396397
assert expected in content
397398

398399

tests/test_markdown.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ def test_event_extra_keys_in_correct_order(tmp_path):
194194
print(content)
195195
content = " ".join(content.split())
196196
assert (
197-
r"<ul><li>alice: two</li>"
197+
r"<ul><li>And1WithExtraCasing: four</li>"
198+
r"<li>alice: two</li>"
198199
r"<li>bob: three</li>"
199200
r"<li>charlie: one</li></ul>" in content
200201
)

tests/test_swift.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ def test_event_extra_keys_in_correct_order(tmp_path):
288288
content = " ".join(content.split())
289289
assert (
290290
"struct ExampleExtra: EventExtras "
291-
"{ var alice: String? var bob: String? var charlie: String?" in content
291+
"{ var and1withextracasing: Bool? var alice: String? var bob: String? var charlie: String?" in content
292292
)
293-
assert ', ["alice", "bob", "charlie"]' in content
293+
assert ', ["And1WithExtraCasing", "alice", "bob", "charlie"]' in content
294294

295295

296296
def test_event_extra_keys_with_types(tmp_path):

0 commit comments

Comments
 (0)