guan404ming commented on code in PR #69295:
URL: https://github.com/apache/airflow/pull/69295#discussion_r3557291988


##########
task-sdk/src/airflow/sdk/coordinators/node/coordinator.py:
##########
@@ -45,6 +46,34 @@
 
 BUNDLE_FILENAME = "bundle.mjs"
 METADATA_FILENAME = "airflow-metadata.yaml"
+EMBEDDED_METADATA_MARKER = b"//# airflowMetadata="
+# Metadata sits on the bundle's first line; a bounded read is enough.
+EMBEDDED_METADATA_HEAD_BYTES = 1 << 20
+
+
+def _read_embedded_metadata(bundle_path: pathlib.Path) -> dict[str, Any] | 
None:
+    """
+    Read the manifest ``airflow-ts-pack`` embeds in the bundle itself.
+
+    The packer prepends the ``airflow-metadata.yaml`` content as a leading
+    ``//# airflowMetadata=<base64>`` line comment, keeping bundle and metadata
+    a single artifact. Returns ``None`` when the bundle has no such marker.
+    """
+    try:
+        with bundle_path.open("rb") as bundle_file:
+            head = bundle_file.read(EMBEDDED_METADATA_HEAD_BYTES)
+    except OSError as exc:
+        raise ValueError(f"cannot read {bundle_path.name}: {exc}") from exc
+
+    if not head.startswith(EMBEDDED_METADATA_MARKER):
+        return None

Review Comment:
   Makes sense for integrity checking and source viewing. The head comment 
could point at section offsets as you describe. Prefer to keep this PR to the 
packing flow and follow up separately, WDYT?



-- 
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