Skip to content

Commit d13bbbc

Browse files
fix: Some fixes to make ingest-replay-recordings usable (#135)
Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
1 parent 10035c4 commit d13bbbc

File tree

7 files changed

+38
-68
lines changed

7 files changed

+38
-68
lines changed
Binary file not shown.
Binary file not shown.

python/generate_python_types.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ def run(target_folder: str = "python/sentry_kafka_schemas/schema_types/") -> Non
2020
schema_data = sentry_kafka_schemas.sentry_kafka_schemas._get_schema(
2121
topic_name, version
2222
)
23-
if schema_data["type"] != "json":
24-
continue
2523

2624
schema_tmp_typename_base = f"{topic_name.replace('-', '_')}_v{version}"
2725
schema_tmp_module_name = schema_tmp_typename_base.lower()

python/requirements-build.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
# Cannot upgrade to 2.2.0 due to issues described in https://github.com/sbrunner/jsonschema-gentypes/issues/469
12
jsonschema-gentypes==1.5.0

python/tests/test_valid_schemas.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ def _validate_title(obj: Any) -> None:
4141

4242
used_titles.add(title)
4343

44+
if (
45+
"properties" in obj
46+
or "additionalProperites" in obj
47+
or "patternProperties" in obj
48+
or "required" in obj
49+
) and obj.get("type") != "object":
50+
# Impose restriction so that types will be good:
51+
# https://github.com/sbrunner/jsonschema-gentypes/issues/469
52+
raise AssertionError(
53+
"type=object needs to be specified explicitly on all schemas, if properties are defined"
54+
)
55+
4456
for value in obj.get("properties", {}).values():
4557
_validate_title(value)
4658

schemas/ingest-replay-recordings.v1.schema.json

Lines changed: 20 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,24 @@
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"title": "replay_recording",
44
"description": "A replay recording, or a chunk thereof",
5-
"anyOf": [
6-
{
7-
"properties": {
8-
"type": { "const": "replay_recording" },
9-
"replay_id": { "type": "string" },
10-
"key_id": { "type": ["null", "integer"] },
11-
"org_id": { "type": "integer", "minimum": 0 },
12-
"project_id": { "type": "integer", "minimum": 0 },
13-
"received": { "type": "number", "minimum": 0 },
14-
"retention_days": { "type": "integer" },
15-
"replay_recording": { "$ref": "#/definitions/ChunkMeta" }
16-
},
17-
"required": [
18-
"type",
19-
"replay_id",
20-
"org_id",
21-
"project_id",
22-
"received",
23-
"retention_days",
24-
"replay_recording"
25-
]
26-
},
27-
{
28-
"properties": {
29-
"type": { "const": "replay_recording_chunk" },
30-
"payload": { "description": "msgpack bytes" },
31-
"replay_id": { "type": "string" },
32-
"project_id": { "type": "integer", "minimum": 0 },
33-
"id": { "type": "string" },
34-
"chunk_index": { "type": "integer", "minimum": 0 }
35-
},
36-
"required": ["type", "replay_id", "project_id", "id", "chunk_index"]
37-
},
38-
{
39-
"properties": {
40-
"type": { "const": "replay_recording_not_chunked" },
41-
"replay_id": { "type": "string" },
42-
"key_id": { "type": ["null", "integer"] },
43-
"org_id": { "type": "integer", "minimum": 0 },
44-
"project_id": { "type": "integer", "minimum": 0 },
45-
"received": { "type": "number", "minimum": 0 },
46-
"retention_days": { "type": "integer" },
47-
"payload": { "description": "msgpack bytes" }
48-
},
49-
"required": [
50-
"type",
51-
"replay_id",
52-
"org_id",
53-
"project_id",
54-
"received",
55-
"retention_days",
56-
"payload"
57-
]
58-
}
59-
],
60-
"definitions": {
61-
"ChunkMeta": {
62-
"title": "chunk_meta",
63-
"properties": {
64-
"id": { "type": "string" },
65-
"chunks": { "type": "integer" },
66-
"size": { "type": "integer" }
67-
},
68-
"required": ["id", "chunks"]
69-
}
70-
}
5+
"type": "object",
6+
"properties": {
7+
"type": { "const": "replay_recording_not_chunked" },
8+
"replay_id": { "type": "string" },
9+
"key_id": { "type": ["null", "integer"] },
10+
"org_id": { "type": "integer", "minimum": 0 },
11+
"project_id": { "type": "integer", "minimum": 0 },
12+
"received": { "type": "integer", "minimum": 0 },
13+
"retention_days": { "type": "integer" },
14+
"payload": { "description": "msgpack bytes" }
15+
},
16+
"required": [
17+
"type",
18+
"replay_id",
19+
"org_id",
20+
"project_id",
21+
"received",
22+
"retention_days",
23+
"payload"
24+
]
7125
}

scripts/edit-msgpack

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
set -xe
3+
./scripts/msgpack2py < "$1" > /tmp/edit.msgpack
4+
$EDITOR /tmp/edit.msgpack
5+
./scripts/py2msgpack < /tmp/edit.msgpack > "$1"

0 commit comments

Comments
 (0)