kaxil commented on code in PR #75055:
URL: https://github.com/apache/airflow/pull/75055#discussion_r4314055688


##########
scripts/ci/prek/generate_yaml_importer_schema.py:
##########
@@ -49,6 +50,7 @@ def build_schema() -> str:
     head = get_bundle().versions[0].value  # newest-first
     schema = DagDocument.model_json_schema(by_alias=True)
     schema["$schema"] = "https://json-schema.org/draft/2020-12/schema";
+    schema["$id"] = schema_from_version(head)

Review Comment:
   With `$id` set, the committed `schema.json` now contains both `$schema` and 
the Dag URL prefix, so it passes the `might_contain_dag` sniff in importer.py 
(`b"$schema" in data and _DAG_SCHEMA_PREFIX in data`). That's the exact case 
the comment above `_DAG_SCHEMA_PREFIX` says the sniff is there to skip. It only 
matters when someone adds `.json` to the importer's `extensions` (which 
yaml-dags.rst suggests for JSON documents) and keeps a copy of the schema in 
the bundle, but then the schema file shows up as a parse error ("is not a 
canonical schema URL"). Could the sniff match the prefix as the value of 
`$schema`, e.g. `rb'\$schema["\']?\s*:\s*["\']?' + 
re.escape(_DAG_SCHEMA_PREFIX)`, rather than anywhere in the file?



##########
dev/breeze/src/airflow_breeze/utils/publish_docs_to_s3.py:
##########
@@ -398,6 +398,7 @@ def add_redirect(self, path: str):
 SCHEMA_VERSION_FIELDS: dict[str, str] = {
     "execution-api": "info.version",
     "supervisor-schema": "api_version",
+    "dag": "$id",

Review Comment:
   The comment above this map still says each field carries the version date, 
but `$id` is the full URL, and the `"/" in version` strip below now runs for 
every schema type. Maybe mention the URL case in that comment and only strip 
for `dag`?



##########
dev/breeze/src/airflow_breeze/commands/release_management_commands.py:
##########
@@ -4917,6 +4917,12 @@ def publish_docs_to_s3(
     help="Path to the generated Supervisor schema JSON file.",
     type=click.Path(exists=True, dir_okay=False, path_type=Path),
 )
[email protected](
+    "--dag",
+    "dag",

Review Comment:
   Nit: click already derives `dag` from `--dag`, and the two sibling options 
don't pass the name.
   
   ```suggestion
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to