Skip to content

Support v7 of octokit/webhooks schema #34

Closed
@zegl

Description

@zegl

I've noticed that the generation step has stopped working since octokit/webhooks v7 was released. https://github.com/octokit/webhooks/releases/tag/v7.0.0

Downgrading to the latest v6 version fixes the generation temporarily, but I suppose that supporting v7 is the best way forward.

diff --git a/pyproject.toml b/pyproject.toml
index 190b460..684a886 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -124,8 +124,12 @@ output_dir = "githubkit/rest/"
 "/components/schemas/team-organization/properties/company" = { type = ["string", "null"] }
 "/components/schemas/team-organization/properties/email" = { type = ["string", "null"] }

 [tool.codegen.webhook]
-schema_source = "https://unpkg.com/@octokit/webhooks-schemas/schema.json"
+schema_source = "https://unpkg.com/@octokit/webhooks-schemas@6.11.0/schema.json"
 output = "githubkit/webhooks/models.py"
 types_output = "githubkit/webhooks/types.py"

This is the log from the failure:

2023-06-07 13:15:57,263 INFO Start getting Webhook source...
2023-06-07 13:15:57,362 INFO HTTP Request: GET https://unpkg.com/@octokit/webhooks-schemas/schema.json "HTTP/1.1 302 Found"
2023-06-07 13:15:57,403 INFO HTTP Request: GET https://unpkg.com/@octokit/webhooks-schemas@7.0.2/schema.json "HTTP/1.1 200 OK"
2023-06-07 13:15:57,422 INFO Getting schema from https://unpkg.com/@octokit/webhooks-schemas/schema.json succeeded!
2023-06-07 13:15:57,422 INFO Start parsing Webhook spec...
Traceback (most recent call last):
  File "/Users/gustav/src/githubkit/codegen/parser/schemas/model_schema.py", line 218, in _add_if_no_conflict
    prop = _merge_property(
           ^^^^^^^^^^^^^^^^
  File "/Users/gustav/src/githubkit/codegen/parser/schemas/model_schema.py", line 184, in _merge_property
    schema = _merge_schema(
             ^^^^^^^^^^^^^^
  File "/Users/gustav/src/githubkit/codegen/parser/schemas/model_schema.py", line 172, in _merge_schema
    raise RuntimeError(f"Cannot merge schema for {name}: {first!r}; {second!r}")
RuntimeError: Cannot merge schema for resolution: UnionSchema(title=None, description='**Required when the `state` is `resolved`.** The reason for resolving the alert.', default=None, examples=None, schemas=[NoneSchema(title=None, description='**Required when the `state` is `resolved`.** The reason for resolving the alert.', default=None, examples=None), EnumSchema(title=None, description='**Required when the `state` is `resolved`.** The reason for resolving the alert.', default=None, examples=None, values=['false_positive', 'wont_fix', 'revoked', 'used_in_tests'])], discriminator=None); EnumSchema(title=None, description=None, default=None, examples=None, values=['false_positive', 'wontfix', 'revoked', 'used_in_tests'])

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/gustav/src/githubkit/codegen/__main__.py", line 9, in <module>
    build()
  File "/Users/gustav/src/githubkit/codegen/__init__.py", line 156, in build
    parsed_data = parse_webhook_schema(source, config.webhook, config)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gustav/src/githubkit/codegen/parser/__init__.py", line 86, in parse_webhook_schema
    root_schema = parse_schema(source, "webhook_schema")
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gustav/src/githubkit/codegen/parser/schemas/__init__.py", line 56, in parse_schema
    schema = build_union_schema(source, class_name, base_source)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gustav/src/githubkit/codegen/parser/schemas/union_schema.py", line 84, in build_union_schema
    _build_sub_schema(
  File "/Users/gustav/src/githubkit/codegen/parser/schemas/union_schema.py", line 52, in _build_sub_schema
    schema = parse_schema(
             ^^^^^^^^^^^^^
  File "/Users/gustav/src/githubkit/codegen/parser/schemas/__init__.py", line 56, in parse_schema
    schema = build_union_schema(source, class_name, base_source)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gustav/src/githubkit/codegen/parser/schemas/union_schema.py", line 84, in build_union_schema
    _build_sub_schema(
  File "/Users/gustav/src/githubkit/codegen/parser/schemas/union_schema.py", line 52, in _build_sub_schema
    schema = parse_schema(
             ^^^^^^^^^^^^^
  File "/Users/gustav/src/githubkit/codegen/parser/schemas/__init__.py", line 70, in parse_schema
    schema = build_model_schema(source, class_name, base_source)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gustav/src/githubkit/codegen/parser/schemas/model_schema.py", line 299, in build_model_schema
    schema.properties = _process_properties(source, class_name, base_source)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gustav/src/githubkit/codegen/parser/schemas/model_schema.py", line 264, in _process_properties
    prop_schema = parse_schema(
                  ^^^^^^^^^^^^^
  File "/Users/gustav/src/githubkit/codegen/parser/schemas/__init__.py", line 70, in parse_schema
    schema = build_model_schema(source, class_name, base_source)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gustav/src/githubkit/codegen/parser/schemas/model_schema.py", line 299, in build_model_schema
    schema.properties = _process_properties(source, class_name, base_source)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gustav/src/githubkit/codegen/parser/schemas/model_schema.py", line 245, in _process_properties
    _add_if_no_conflict(prop)
  File "/Users/gustav/src/githubkit/codegen/parser/schemas/model_schema.py", line 225, in _add_if_no_conflict
    raise RuntimeError(
RuntimeError: Error while creating model SecretScanningAlertResolvedPropAlert from https://unpkg.com/@octokit/webhooks-schemas/schema.json#/definitions/secret_scanning_alert$resolved/properties/alert, duplicated property resolution

Metadata

Metadata

Assignees

No one assigned

    Labels

    WebHookbugSomething isn't workingschemaschema related

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions