Merge pull request 'cultnet-py: schema catalog describes cultnet.error.v0 as the contract does' (#17) from libby/cultnet-py-error-catalog into main
Some checks failed
CultMesh QUIC native / Build win32-x64 (push) Has been skipped
CultMesh QUIC native / Build linux-x64 (push) Has been skipped
CultMesh QUIC native / Release native binaries (push) Has been skipped
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (push) Has been cancelled
CultMesh QUIC native / Verify committed binaries match SHA256SUMS (push) Has been cancelled
Some checks failed
CultMesh QUIC native / Build win32-x64 (push) Has been skipped
CultMesh QUIC native / Build linux-x64 (push) Has been skipped
CultMesh QUIC native / Release native binaries (push) Has been skipped
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (push) Has been cancelled
CultMesh QUIC native / Verify committed binaries match SHA256SUMS (push) Has been cancelled
This commit is contained in:
commit
0fd9d25527
2 changed files with 20 additions and 7 deletions
|
|
@ -12,6 +12,17 @@ PEER_EXCHANGE_REQUEST = "cultmesh.peer_exchange_request.v0"
|
||||||
TRANSPORT_PROFILE_SCHEMA_VERSION = "cultnet.transport_profile.v0"
|
TRANSPORT_PROFILE_SCHEMA_VERSION = "cultnet.transport_profile.v0"
|
||||||
TRANSPORT_PROFILE_SCHEMA_ID = f"{CULTNET_SCHEMA_BASE}/cultnet.transport-profile.schema.json"
|
TRANSPORT_PROFILE_SCHEMA_ID = f"{CULTNET_SCHEMA_BASE}/cultnet.transport-profile.schema.json"
|
||||||
|
|
||||||
|
# The closed code set of contracts/cultnet/cultnet.error.schema.json; a code outside it is one coordinated change across every runtime.
|
||||||
|
CULTNET_ERROR_CODES = (
|
||||||
|
"selection_invalid",
|
||||||
|
"cursor_stale",
|
||||||
|
"cursor_invalid",
|
||||||
|
"reference_outside_target",
|
||||||
|
"variant_unsupported",
|
||||||
|
"unowned_schema",
|
||||||
|
"write_not_authorized",
|
||||||
|
)
|
||||||
|
|
||||||
WIRE_MESSAGE_SCHEMA_VERSIONS = (
|
WIRE_MESSAGE_SCHEMA_VERSIONS = (
|
||||||
("cultnet.hello.v0", "CultNet Hello Message", f"{CULTNET_SCHEMA_BASE}/cultnet.hello.schema.json"),
|
("cultnet.hello.v0", "CultNet Hello Message", f"{CULTNET_SCHEMA_BASE}/cultnet.hello.schema.json"),
|
||||||
("cultnet.error.v0", "CultNet Error Message", f"{CULTNET_SCHEMA_BASE}/cultnet.error.schema.json"),
|
("cultnet.error.v0", "CultNet Error Message", f"{CULTNET_SCHEMA_BASE}/cultnet.error.schema.json"),
|
||||||
|
|
@ -269,7 +280,7 @@ def shared_contract_schema_json(schema_id: str, title: str, schema_version: str)
|
||||||
def wire_message_required_fields(schema_version: str) -> list[str]:
|
def wire_message_required_fields(schema_version: str) -> list[str]:
|
||||||
required = {
|
required = {
|
||||||
"cultnet.hello.v0": ["schemaVersion", "runtimeId"],
|
"cultnet.hello.v0": ["schemaVersion", "runtimeId"],
|
||||||
"cultnet.error.v0": ["schemaVersion", "error"],
|
"cultnet.error.v0": ["schemaVersion", "error", "routingHint", "code", "details"],
|
||||||
"cultnet.login.v0": ["schemaVersion", "nonce", "auth", "password"],
|
"cultnet.login.v0": ["schemaVersion", "nonce", "auth", "password"],
|
||||||
"cultnet.register.v0": ["schemaVersion", "nonce", "email", "password", "name"],
|
"cultnet.register.v0": ["schemaVersion", "nonce", "email", "password", "name"],
|
||||||
"cultnet.verify.v0": ["schemaVersion", "nonce", "session"],
|
"cultnet.verify.v0": ["schemaVersion", "nonce", "session"],
|
||||||
|
|
@ -355,10 +366,10 @@ def wire_message_schema_properties(schema_version: str) -> dict[str, Any]:
|
||||||
"supportsSchemaCatalog": {"type": "boolean"},
|
"supportsSchemaCatalog": {"type": "boolean"},
|
||||||
},
|
},
|
||||||
"cultnet.error.v0": {
|
"cultnet.error.v0": {
|
||||||
"messageId": common["messageId"],
|
"error": {"type": "string", "minLength": 1},
|
||||||
"error": {"type": "string"},
|
"routingHint": {"type": ["object", "null"]},
|
||||||
"code": {"type": "string"},
|
"code": {"type": ["string", "null"], "enum": [None, *CULTNET_ERROR_CODES]},
|
||||||
"details": {"type": "object", "additionalProperties": True},
|
"details": {"type": ["object", "null"]},
|
||||||
},
|
},
|
||||||
"cultnet.login.v0": {
|
"cultnet.login.v0": {
|
||||||
"nonce": {"type": "string", "minLength": 1},
|
"nonce": {"type": "string", "minLength": 1},
|
||||||
|
|
|
||||||
|
|
@ -2235,9 +2235,11 @@ class CultNetTests(unittest.TestCase):
|
||||||
self.assertEqual(delete_schema["properties"]["recordKey"]["type"], "string")
|
self.assertEqual(delete_schema["properties"]["recordKey"]["type"], "string")
|
||||||
|
|
||||||
error_schema = json.loads(by_version["cultnet.error.v0"]["schemaJson"])
|
error_schema = json.loads(by_version["cultnet.error.v0"]["schemaJson"])
|
||||||
self.assertEqual(error_schema["required"], ["schemaVersion", "error"])
|
contract = json.loads((Path(__file__).resolve().parents[3] / "contracts" / "cultnet" / "cultnet.error.schema.json").read_text(encoding="utf-8"))
|
||||||
|
self.assertEqual(error_schema["required"], contract["required"])
|
||||||
|
self.assertEqual(sorted(error_schema["properties"]), sorted(contract["properties"]))
|
||||||
self.assertEqual(error_schema["properties"]["error"]["type"], "string")
|
self.assertEqual(error_schema["properties"]["error"]["type"], "string")
|
||||||
self.assertIn("details", error_schema["properties"])
|
self.assertEqual(error_schema["properties"]["code"]["enum"], contract["properties"]["code"]["enum"])
|
||||||
|
|
||||||
login_schema = json.loads(by_version["cultnet.login.v0"]["schemaJson"])
|
login_schema = json.loads(by_version["cultnet.login.v0"]["schemaJson"])
|
||||||
self.assertEqual(login_schema["required"], ["schemaVersion", "nonce", "auth", "password"])
|
self.assertEqual(login_schema["required"], ["schemaVersion", "nonce", "auth", "password"])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue