Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- Fix tests that failed when `SOURCE_DATE_EPOCH` is set in the environment
- Add a `skip_schema_validation` option to `parse_objects` to skip schema validation of input files ([bug 2076540](https://bugzilla.mozilla.org/show_bug.cgi?id=2076540))
- Mark `test_logging` as requiring a web connection
- BUGFIX: Ensure ALL_OBJECT_CHECKS actually run against the known items ([bug 2088071](https://bugzilla.mozilla.org/show_bug.cgi?id=2088071))
- Reserve "tags" and "pings" as ping names. These cannot be used for custom pings

## 22.0.1

Expand Down
13 changes: 11 additions & 2 deletions glean_parser/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,11 +641,20 @@ def _lint_all_objects(
) -> List[GlinterNit]:
nits: List[GlinterNit] = []

pings = objects.get("pings")
pings = {}
metrics = {}

for key, item in objects.items():
if key == "pings":
pings.update(item)
elif key == "tags":
pass
else:
metrics.update(item)

if not pings:
return []

metrics = objects.get("all_metrics")
if not metrics:
return []

Expand Down
12 changes: 11 additions & 1 deletion glean_parser/pings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@
from . import util


RESERVED_PING_NAMES = ["baseline", "metrics", "events", "deletion-request", "default"]
RESERVED_PING_NAMES = [
"baseline",
"metrics",
"events",
"deletion-request",
"default",
"server-deletion-request",
"tags",
"pings",
"health",
]


class Ping:
Expand Down
27 changes: 27 additions & 0 deletions tests/data/reserved_pings.yamlx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Any copyright is dedicated to the Public Domain.
# https://creativecommons.org/publicdomain/zero/1.0/

---
$schema: moz://mozilla.org/schemas/glean/pings/2-0-0

# A list of all reserved ping names.
# This is verified in a test to match the list of defined reserved pings.

metrics: &common
description: A ping
include_client_id: true
bugs:
- https://example.com/bugs
data_reviews:
- https://example.com/reviews
notification_emails:
- CHANGE-ME@test-only.com

baseline: *common
events: *common
deletion-request: *common
default: *common
server-deletion-request: *common
tags: *common
pings: *common
health: *common
2 changes: 2 additions & 0 deletions tests/data/unknown_ping_used.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ all_metrics:
send_in_pings:
- metrics
- events
no_lint:
- METRIC_ON_EVENTS_LIFETIME

non_existent_ping:
<<: *defaults
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def test_unknown_pings_lint():
assert len(errs) == 0

nits = lint.lint_metrics(all_objects.value, parser_config={})
assert len(nits) == 2
assert len(nits) == 1
assert nits[0].check_name == "UNKNOWN_PING_REFERENCED"
assert nits[0].name == "all_metrics.non_existent_ping"
assert "does-not-exist" in nits[0].msg
Expand Down
10 changes: 10 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import pytest

from glean_parser import metrics
from glean_parser import pings
from glean_parser import parser

import util
Expand Down Expand Up @@ -1637,3 +1638,12 @@ def test_categories():

errs = list(all_metrics)
assert len(errs) == 0


def test_reserved_pings():
all_metrics = parser.parse_objects(ROOT / "data" / "reserved_pings.yamlx")

errors = list(all_metrics)
assert len(errors) == len(pings.RESERVED_PING_NAMES)
for error in errors:
assert "Ping uses a reserved name" in error
Loading