turbaszek commented on a change in pull request #9322:
URL: https://github.com/apache/airflow/pull/9322#discussion_r453370705



##########
File path: airflow/api_connexion/endpoints/dag_source_endpoint.py
##########
@@ -14,13 +14,34 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+import logging
 
-# TODO(mik-laj): We have to implement it.
-#     Do you want to help? Please look at: 
https://github.com/apache/airflow/issues/8137
+from flask import Response, current_app, request
+from itsdangerous import BadSignature, URLSafeSerializer
 
+from airflow.api_connexion.exceptions import NotFound
+from airflow.api_connexion.schemas.dag_source_schema import dag_source_schema
+from airflow.models.dagcode import DagCode
 
-def get_dag_source():
+log = logging.getLogger(__name__)
+
+
+def get_dag_source(file_token: str):
     """
     Get source code using file token
     """
-    raise NotImplementedError("Not implemented yet.")
+    secret_key = current_app.config["SECRET_KEY"]
+    auth_s = URLSafeSerializer(secret_key)
+    try:
+        path = auth_s.loads(file_token)
+        dag_source = DagCode.code(path)
+    except (BadSignature, FileNotFoundError):
+        raise NotFound("Dag Source not found")

Review comment:
       ```suggestion
           raise NotFound("Dag source not found")
   ```




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

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


Reply via email to