Skip to content

Add status change topic#155

Open
kevinwallimann wants to merge 13 commits into
masterfrom
feature/151-add-status-change-topic
Open

Add status change topic#155
kevinwallimann wants to merge 13 commits into
masterfrom
feature/151-add-status-change-topic

Conversation

@kevinwallimann
Copy link
Copy Markdown

@kevinwallimann kevinwallimann commented May 20, 2026

Overview

See

Release Notes

  • Add status change topic

Related

Closes #151

Summary by CodeRabbit

  • New Features

    • Added a status-change event topic with a validation schema for job lifecycle events.
    • Writers and publishing flow now support an optional message key used for keyed delivery/partitioning.
    • Topic-key extraction configured so messages can supply a per-topic key.
  • Chores

    • Added topic key configuration and granted access for the new topic.
    • Enabled discovery/listing of the new topic and updated local test runner settings.
  • Tests

    • Expanded unit tests for topic discovery, key extraction, and writer key propagation.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds a new status_change topic (constant, schema, access), topic-keys config and loader, HandlerTopic message-key resolution and POST wiring, writer signature updates to accept message_key, and corresponding unit tests and editor test settings.

Changes

Status Change Topic Support

Layer / File(s) Summary
Topic constant and schema definition
src/utils/constants.py, conf/topic_schemas/status_change.json, conf/access.json, conf/config.json, conf/topic_keys.json
Adds TOPIC_STATUS_CHANGE = "public.cps.za.status_change"; introduces status_change.json schema with event-type conditional validation; registers public.cps.za.status_change in conf/access.json; adds topic_keys_config and conf/topic_keys.json.
Config loader and handler integration
src/utils/config_loader.py, src/handlers/handler_topic.py, src/event_gate_lambda.py
Adds _load_json_from_path() helper; implements load_topic_keys_config() and maps status_change.json to the topic; HandlerTopic loads topic_keys, resolves per-message message_key during POST and passes it to writer.write(...); event_gate_lambda includes with_load_topic_keys_config() in the handler init chain.
Writers: interface and implementations
src/writers/writer.py, src/writers/writer_kafka.py, src/writers/writer_eventbridge.py, src/writers/writer_postgres.py
Extends Writer.write(..., message_key: str = "") signature; Kafka writer forwards message_key to producer key=; EventBridge/Postgres signatures updated to accept the parameter.
Tests and editor settings
tests/unit/handlers/test_handler_topic.py, tests/unit/utils/test_config_loader.py, tests/unit/writers/test_writer_kafka.py, .vscode/settings.json
Adds/updates tests for topic discovery, topic-keys loading (local and S3), normalize validation, POST dispatch message_key behavior, and Kafka writer key handling; updates VSCode pytest settings.

Sequence Diagram

sequenceDiagram
  participant Client
  participant HandlerTopic as src/handlers/handler_topic.py
  participant ConfigLoader as src/utils/config_loader.py
  participant TopicKeys as conf/topic_keys.json
  participant WriterKafka as src/writers/writer_kafka.py
  Client->>HandlerTopic: POST /topics/{topic} with message
  HandlerTopic->>ConfigLoader: (on init) load topic_keys_config
  HandlerTopic->>TopicKeys: lookup configured key field for topic
  HandlerTopic->>WriterKafka: writer.write(topic, message, message_key)
  WriterKafka->>KafkaProducer: produce(topic=..., key=message_key, value=json_bytes)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • AbsaOSS/EventGate#104: Overlaps writer/HandlerTopic integration and writer.write invocation path.
  • AbsaOSS/EventGate#108: Related to builder-style handler initialization that this PR extends with topic-keys loading.
  • AbsaOSS/EventGate#93: Prior changes to HandlerTopic dispatch that this PR augments with message-key plumbing.

Suggested labels

enhancement

Suggested reviewers

  • petr-pokorny-absa
  • oto-macenauer-absa
  • lsulak

Poem

🐰 A tiny schema hops on by,
Keys mapped neat and tests nearby,
Handlers read and writers sing,
Messages carry a routing string,
EventGate hums — a tidy sky.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 78.26% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a new status_change topic to EventGate, which directly reflects the primary objective of this pull request.
Description check ✅ Passed The PR description includes Overview, Release Notes, and Related sections matching the template structure, with links to design documentation and reference to issue #151.
Linked Issues check ✅ Passed The PR successfully implements all five acceptance criteria: topic is defined, schema supports required fields, producers can publish via API, consumers can subscribe, and topic is documented in the registry.
Out of Scope Changes check ✅ Passed All changes are directly related to the status_change topic implementation. Writer signature updates across all implementations align with the new message_key parameter introduced by handler_topic.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/151-add-status-change-topic

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/unit/handlers/test_handler_topic.py (1)

90-90: ⚡ Quick win

Add one POST-path test for public.cps.za.status-change schema validation.

Current additions validate discovery/listing only. A valid + invalid POST case for the new topic would protect the end-to-end contract (load + validate + reject bad payloads) from regressions.

Also applies to: 103-107, 117-117

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/handlers/test_handler_topic.py` at line 90, Add a new test
function (e.g., test_post_status_change_schema_validation) in the existing
test_handler_topic suite that exercises the POST path for the schema named
"public.cps.za.status-change": send one valid POST payload (matching the schema,
e.g., including execution_id as string) and assert the handler accepts it
(status accepted/success), then send an obviously invalid payload (e.g.,
execution_id missing or wrong type) and assert the handler rejects it with a
validation error (400 or rejection response and an error message referencing the
schema/field); place both assertions in the same test to ensure load+validate
behavior is covered end-to-end.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@conf/topic_schemas/status_change.json`:
- Around line 20-33: The schema currently treats tenant_id as optional and lacks
explicit previous_state/new_state fields; update status_change.json to make the
application identifier required (mark "tenant_id" as required in the root
"required" array or otherwise add a required "application_id" equivalent), add
"previous_state" and "new_state" properties (type "string", non-nullable) to the
schema, and include those two fields in the schema's "required" array so every
status_change event must carry tenant_id plus previous_state and new_state;
apply the same changes to the other schema blocks noted (lines referenced in the
review).
- Around line 52-55: The schema defines "timestamp_event" as epoch milliseconds
but uses "type": "number" which allows fractions; change the "timestamp_event"
field in the JSON schema to use "type": "integer" (and add "minimum": 0 if you
want to enforce non-negative timestamps) so the schema enforces
whole-millisecond epoch values.

---

Nitpick comments:
In `@tests/unit/handlers/test_handler_topic.py`:
- Line 90: Add a new test function (e.g.,
test_post_status_change_schema_validation) in the existing test_handler_topic
suite that exercises the POST path for the schema named
"public.cps.za.status-change": send one valid POST payload (matching the schema,
e.g., including execution_id as string) and assert the handler accepts it
(status accepted/success), then send an obviously invalid payload (e.g.,
execution_id missing or wrong type) and assert the handler rejects it with a
validation error (400 or rejection response and an error message referencing the
schema/field); place both assertions in the same test to ensure load+validate
behavior is covered end-to-end.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 469ed8af-1aad-4a69-aa28-c2f10a0eb96a

📥 Commits

Reviewing files that changed from the base of the PR and between a0b6f6f and a6dc8b4.

📒 Files selected for processing (7)
  • conf/access.json
  • conf/topic_schemas/status_change.json
  • src/handlers/handler_topic.py
  • src/utils/config_loader.py
  • src/utils/constants.py
  • tests/unit/handlers/test_handler_topic.py
  • tests/unit/utils/test_config_loader.py

Comment thread conf/topic_schemas/status_change.json
Comment thread conf/topic_schemas/status_change.json
kevinwallimann and others added 2 commits May 20, 2026 16:49
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
conf/topic_schemas/status_change.json (1)

34-41: 💤 Low value

Minor: stray leading space in source_app description.

Line 36's description starts with a leading space (" Standardized source application name..."). Trivial cleanup while you're touching the field.

✏️ Proposed tweak
-            "description": " Standardized source application name (aqueduct, unify, lum, etc)"
+            "description": "Standardized source application name (aqueduct, unify, lum, etc)"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@conf/topic_schemas/status_change.json` around lines 34 - 41, The description
value for the JSON schema field "source_app" contains a stray leading space;
update the "source_app" property's "description" (in status_change.json) to
remove the leading whitespace so it reads "Standardized source application name
(aqueduct, unify, lum, etc)" exactly, ensuring the JSON string has no extra
leading character.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@conf/topic_schemas/status_change.json`:
- Around line 34-41: The description value for the JSON schema field
"source_app" contains a stray leading space; update the "source_app" property's
"description" (in status_change.json) to remove the leading whitespace so it
reads "Standardized source application name (aqueduct, unify, lum, etc)"
exactly, ensuring the JSON string has no extra leading character.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 61200d85-a19c-420a-9e0c-38cd27ac8d69

📥 Commits

Reviewing files that changed from the base of the PR and between a6dc8b4 and c6e6750.

📒 Files selected for processing (1)
  • conf/topic_schemas/status_change.json

Copy link
Copy Markdown
Collaborator

@oto-macenauer-absa oto-macenauer-absa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see couple issue that should be fixed:
postgres writer - this one is not implemented - it requires specific sql defined, could be opted out if sql peristence is not desired but with the current state it will spam "unknow topic"errors
kafka writer - at the moment the key for the message is not used, but with this topic, if we need the ordering, it should use some key

is the ADR going to be part of the commit? There are some inconsistencies, e.g. country_code vs country, incomplete events, also isn't the status_type duplicate with the event_type?

Also I'm not sure EventGate works with the "allOf" conditional validation, this should be tested.

Comment thread src/utils/constants.py Outdated
Comment thread src/utils/constants.py
TOPIC_TEST = "public.cps.za.test"
TOPIC_STATUS_CHANGE = "public.cps.za.status-change"

SUPPORTED_WRITE_TOPICS: frozenset[str] = frozenset({TOPIC_RUNS, TOPIC_DLCHANGE, TOPIC_TEST})
Copy link
Copy Markdown
Collaborator

@oto-macenauer-absa oto-macenauer-absa May 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing the status_change topic in SUPPORTED_WRITE_TOPICS

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm also there is no addition of this new queue in src/writers/sql/inserts.sql - do we want to push it into our Postgres for analytical purposes or no? It might become quite massive over time though

"description": "Environment (dev, uat, pre-prod, prod, test or others)"
},
"timestamp_event": {
"type": "integer",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The runs schema uses "type": "number" for timestamps. Herei s "integer". While epoch milliseconds are integers, the inconsistency may confuse producers.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, number can also be floating point, so integer is the correct choice here. However, your call, rather be consistent but wrong, or eventually fix it in the runs schema as well?

Comment thread conf/topic_schemas/status_change.json Outdated
"properties": {
"event_type": {
"enum": [
"JobCreatedEvent",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I like that you thought about it, but aren't half of these already mandatory? These: source_app and source_app_version and environment so to me only the last 2 make sense here unless I misunderstood how it works.


Another thing - maybe some other event types can also require some mandatory attributes?

Like, JobUpdatedEvent might require status_type or status_detail - this is the primary change that the event would emit, right? Otherwise, what's there to update?


Thinking about this a bit more - mandatory parameters:

  • Consider adding job_name and perhaps even definition_id as required on creation events (identity should be established at creation)
  • Consider making status_type required for "JobCreatedAndStartedEvent", "JobStartedEvent", "JobUpdatedEvent"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I made status_type mandatory for all, even though there is only one valid value for JobCreatedEvent, JobStartedEvent and JobCreatedAndStartedEvent.
  • As for source_app etc. I removed them from generally required, to only mandatory in JobCreatedEvent and JobCreatedAndStartedEvent, since there's no point repeating that information throughout the lifecycle of the job. The job_id is sufficient to identify the job
  • I've added job_name and definition_id to the required parameters in JobCreatedEvent and JobCreatedAndStartedEvent

kevinwallimann and others added 3 commits May 27, 2026 23:57
Comment thread .vscode/settings.json Outdated
Comment on lines +1 to +7
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
} No newline at end of file
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this file committed on purpose? This one is IDE-specific and some parts of the configuration can be moved inside the pyproject.toml, that we use for the project conf setting. Or is there some point of having this on GitHub, I do not see?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I've removed it now. Thanks

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/writers/writer.py (1)

41-52: 🛠️ Refactor suggestion | 🟠 Major | 🏗️ Heavy lift

Align Writer method contracts with repo writer guidelines.

The abstract contract still uses write(...) -> None and check_health() -> str | None, but the writers guideline requires tuple-return contracts. Since this interface is being changed in this PR, please align it now (and cascade to implementations/callers) or explicitly update the guideline before merge.

As per coding guidelines src/writers/*.py: Writers must inherit from Writer(ABC) and implement write(topic, message) -> (bool, str|None) and check_health() -> (bool, str) methods.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/writers/writer.py` around lines 41 - 52, Update the Writer abstract
interface to match the repo guideline: change Writer.write signature to return a
tuple (bool, str|None) instead of None and change Writer.check_health to return
(bool, str) instead of str|None; update the docstrings to document the boolean
success flag and message, and then cascade these signature changes to all
concrete implementations and callers so they return and propagate (success,
message) tuples (look for usages of write and check_health in classes inheriting
Writer and in any code calling those methods and adjust error handling
accordingly).
🧹 Nitpick comments (1)
tests/unit/handlers/test_handler_topic.py (1)

74-118: ⚡ Quick win

Use pytest-mock patching style in these new tests.

These added tests use unittest.mock.patch/patch.object; this repo standard asks for mocker.patch(...) / mocker.patch.object(...) in tests for consistency.

Example conversion pattern
-def test_post_passes_topic_key_to_writers(event_gate_module, make_event, valid_payload):
+def test_post_passes_topic_key_to_writers(event_gate_module, make_event, valid_payload, mocker):
     ...
-    with patch.object(event_gate_module.handler_token, "decode_jwt", return_value={"sub": "TestUser"}):
+    mocker.patch.object(event_gate_module.handler_token, "decode_jwt", return_value={"sub": "TestUser"})
+    ...

As per coding guidelines tests/**/*.py: Use mocker.patch("module.dependency") or mocker.patch.object(Class, "method") for mocking in tests.

Also applies to: 260-302

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/handlers/test_handler_topic.py` around lines 74 - 118, Replace
unittest.mock.patch usage in the new tests with pytest-mock's mocker fixture
calls: in test_load_topic_keys_config_from_local_file and
test_load_topic_keys_config_from_s3 use mocker.patch("builtins.open", ...)
instead of patch(...) and use mocker to create/patch AWS S3 interactions (e.g.,
mocker.patch.object or mocker.patch to stub HandlerTopic dependencies) so mocks
are created via the mocker fixture; keep assertions on
HandlerTopic.with_load_topic_keys_config, handler.topic_keys, and
mock_aws_s3.Bucket/Object calls unchanged while converting all
patch/patch.object usages referenced in these functions to
mocker.patch/mocker.patch.object.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/utils/config_loader.py`:
- Around line 50-65: Run Black on this file to satisfy the formatting CI:
reformat the function _load_json_from_path (and the file) using Black (e.g.,
black src/utils/config_loader.py) so the conditional return lines, argument
annotations, and docstring conform to Black style; ensure you stage the
resulting changes and re-run black --check before pushing.
- Around line 149-184: Restore a _normalize_topic_keys_config(topic_key_data:
dict[str, Any]) function and call it from load_topic_keys_config so the module
exports the expected symbol and returns normalized data; implement
_normalize_topic_keys_config to (1) coerce/validate topic names and field names
to strings, strip surrounding whitespace from both keys and values, and raise
ValueError via _validate_topic_keys_config if a value is not a string, and (2)
return a TopicKeyMap (dict[str, str]) with normalized topic keys (e.g.,
trimmed/lowercased if your tests expect that) before load_topic_keys_config
returns the mapping; update load_topic_keys_config to invoke
_normalize_topic_keys_config(topic_key_data) and return its result instead of
the raw topic_key_data.

In `@tests/unit/utils/test_config_loader.py`:
- Around line 27-34: The test imports a private helper named
_normalize_topic_keys_config from src.utils.config_loader but that symbol
doesn't exist; either add/export a function with that exact name in the
config_loader module (implement it or make it a thin wrapper that calls the
existing public normalizer such as
load_topic_keys_config/_normalize_access_config) or change the test to stop
importing the private helper and use the public API (e.g., call
load_topic_keys_config or the public normalizer). Locate the missing symbol by
checking the config_loader module and either define _normalize_topic_keys_config
there or update tests/unit/utils/test_config_loader.py to import and assert
behavior via the public functions instead.

---

Outside diff comments:
In `@src/writers/writer.py`:
- Around line 41-52: Update the Writer abstract interface to match the repo
guideline: change Writer.write signature to return a tuple (bool, str|None)
instead of None and change Writer.check_health to return (bool, str) instead of
str|None; update the docstrings to document the boolean success flag and
message, and then cascade these signature changes to all concrete
implementations and callers so they return and propagate (success, message)
tuples (look for usages of write and check_health in classes inheriting Writer
and in any code calling those methods and adjust error handling accordingly).

---

Nitpick comments:
In `@tests/unit/handlers/test_handler_topic.py`:
- Around line 74-118: Replace unittest.mock.patch usage in the new tests with
pytest-mock's mocker fixture calls: in
test_load_topic_keys_config_from_local_file and
test_load_topic_keys_config_from_s3 use mocker.patch("builtins.open", ...)
instead of patch(...) and use mocker to create/patch AWS S3 interactions (e.g.,
mocker.patch.object or mocker.patch to stub HandlerTopic dependencies) so mocks
are created via the mocker fixture; keep assertions on
HandlerTopic.with_load_topic_keys_config, handler.topic_keys, and
mock_aws_s3.Bucket/Object calls unchanged while converting all
patch/patch.object usages referenced in these functions to
mocker.patch/mocker.patch.object.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 99ff74a3-b46d-4653-a0ee-41527d804eba

📥 Commits

Reviewing files that changed from the base of the PR and between f2d7278 and 12de355.

📒 Files selected for processing (13)
  • conf/config.json
  • conf/topic_keys.json
  • conf/topic_schemas/status_change.json
  • src/event_gate_lambda.py
  • src/handlers/handler_topic.py
  • src/utils/config_loader.py
  • src/writers/writer.py
  • src/writers/writer_eventbridge.py
  • src/writers/writer_kafka.py
  • src/writers/writer_postgres.py
  • tests/unit/handlers/test_handler_topic.py
  • tests/unit/utils/test_config_loader.py
  • tests/unit/writers/test_writer_kafka.py
✅ Files skipped from review due to trivial changes (1)
  • conf/config.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • conf/topic_schemas/status_change.json

Comment thread src/utils/config_loader.py
Comment thread src/utils/config_loader.py
Comment thread tests/unit/utils/test_config_loader.py
@kevinwallimann
Copy link
Copy Markdown
Author

@oto-macenauer-absa

kafka writer - at the moment the key for the message is not used, but with this topic, if we need the ordering, it should use some key

I've added per-topic configuration to specify a property of the event to use as the key. The fallback value is the empty string

Also I'm not sure EventGate works with the "allOf" conditional validation, this should be tested.
It works. I've tested this locally like this:

>>> from jsonschema import validate
>>> import json
>>> def load_json_file(path):
...     """Load JSON from a file."""
...     with open(path, 'r', encoding='utf-8') as f:
...         return json.load(f)
>>> schema = load_json_file("conf/topic_schemas/status_change.json")
>>> validate(instance=load_json_file("/tmp/message.json"),schema=schema)

Some output:
raise error
jsonschema.exceptions.ValidationError: 'status_type' is a required property
Failed validating 'required' in schema:
{'type': 'object', // full schema printed

Other output:
raise error
jsonschema.exceptions.ValidationError: 'RUNNINadfG' is not one of ['RUNNING']

Failed validating 'enum' in schema['allOf'][1]['then']['properties']['status_type']:
{'enum': ['RUNNING']}

On instance['status_type']:
'RUNNINadfG'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add status_change topic support to EventGate

4 participants