Spaces:
Sleeping
Sleeping
Commit
·
cd1d4e4
1
Parent(s):
c978648
fix: Critical pipeline ID sequencing bug
Browse files- Fixed pipelines not appearing in /sessions/{id}/pipelines endpoint
- Root cause: _create_pipeline_record called AFTER session update
- Solution: Call _create_pipeline_record FIRST (adds pipeline_id to dict), THEN update session
- Now proposed_pipeline in MongoDB includes pipeline_id
- Pipeline status updates now work correctly (pipeline_id is always present)
- Fixes empty pipelines array in API response
- api_routes_v2.py +9 -6
api_routes_v2.py
CHANGED
|
@@ -1141,9 +1141,10 @@ async def chat_unified(
|
|
| 1141 |
prefer_bedrock=bool(prefer_bedrock),
|
| 1142 |
)
|
| 1143 |
|
| 1144 |
-
|
| 1145 |
-
# V3: Create pipeline record in S3 and MongoDB
|
| 1146 |
pipeline_id = _create_pipeline_record(chat_id, pipeline, status="proposed", created_from="request")
|
|
|
|
|
|
|
| 1147 |
|
| 1148 |
pipeline_name = pipeline.get("pipeline_name", "Document Processing")
|
| 1149 |
steps_list = pipeline.get("pipeline_steps", [])
|
|
@@ -1202,9 +1203,10 @@ async def chat_unified(
|
|
| 1202 |
file_path=session.get("current_file"),
|
| 1203 |
prefer_bedrock=bool(prefer_bedrock)
|
| 1204 |
)
|
| 1205 |
-
|
| 1206 |
-
# V3: Create pipeline record for edited pipeline
|
| 1207 |
pipeline_id = _create_pipeline_record(chat_id, new_pipeline, status="proposed", created_from="edit")
|
|
|
|
|
|
|
| 1208 |
|
| 1209 |
formatted = format_pipeline_for_display(new_pipeline)
|
| 1210 |
friendly = formatted + f"\n\n```json\n{json.dumps(new_pipeline, indent=2)}\n```"
|
|
@@ -1556,9 +1558,10 @@ async def chat_unified_stream(
|
|
| 1556 |
file_path=session_local.get("current_file"),
|
| 1557 |
prefer_bedrock=bool(prefer_bedrock)
|
| 1558 |
)
|
| 1559 |
-
|
| 1560 |
-
# V3: Create pipeline record for edited pipeline
|
| 1561 |
pipeline_id = _create_pipeline_record(chat_id, new_pipeline, status="proposed", created_from="edit")
|
|
|
|
|
|
|
| 1562 |
formatted = format_pipeline_for_display(new_pipeline)
|
| 1563 |
friendly = formatted + f"\n\n```json\n{json.dumps(new_pipeline, indent=2)}\n```"
|
| 1564 |
_add_and_mirror_message(chat_id, "assistant", friendly)
|
|
|
|
| 1141 |
prefer_bedrock=bool(prefer_bedrock),
|
| 1142 |
)
|
| 1143 |
|
| 1144 |
+
# V3: Create pipeline record in S3 and MongoDB (adds pipeline_id to dict)
|
|
|
|
| 1145 |
pipeline_id = _create_pipeline_record(chat_id, pipeline, status="proposed", created_from="request")
|
| 1146 |
+
# Now update session with pipeline that includes pipeline_id
|
| 1147 |
+
session_manager.update_session(chat_id, {"proposed_pipeline": pipeline, "state": "pipeline_proposed"})
|
| 1148 |
|
| 1149 |
pipeline_name = pipeline.get("pipeline_name", "Document Processing")
|
| 1150 |
steps_list = pipeline.get("pipeline_steps", [])
|
|
|
|
| 1203 |
file_path=session.get("current_file"),
|
| 1204 |
prefer_bedrock=bool(prefer_bedrock)
|
| 1205 |
)
|
| 1206 |
+
# V3: Create pipeline record for edited pipeline (adds pipeline_id)
|
|
|
|
| 1207 |
pipeline_id = _create_pipeline_record(chat_id, new_pipeline, status="proposed", created_from="edit")
|
| 1208 |
+
# Now update session with pipeline that includes pipeline_id
|
| 1209 |
+
session_manager.update_session(chat_id, {"proposed_pipeline": new_pipeline, "state": "pipeline_proposed"})
|
| 1210 |
|
| 1211 |
formatted = format_pipeline_for_display(new_pipeline)
|
| 1212 |
friendly = formatted + f"\n\n```json\n{json.dumps(new_pipeline, indent=2)}\n```"
|
|
|
|
| 1558 |
file_path=session_local.get("current_file"),
|
| 1559 |
prefer_bedrock=bool(prefer_bedrock)
|
| 1560 |
)
|
| 1561 |
+
# V3: Create pipeline record for edited pipeline (adds pipeline_id)
|
|
|
|
| 1562 |
pipeline_id = _create_pipeline_record(chat_id, new_pipeline, status="proposed", created_from="edit")
|
| 1563 |
+
# Now update session with pipeline that includes pipeline_id
|
| 1564 |
+
session_manager.update_session(chat_id, {"proposed_pipeline": new_pipeline, "state": "pipeline_proposed"})
|
| 1565 |
formatted = format_pipeline_for_display(new_pipeline)
|
| 1566 |
friendly = formatted + f"\n\n```json\n{json.dumps(new_pipeline, indent=2)}\n```"
|
| 1567 |
_add_and_mirror_message(chat_id, "assistant", friendly)
|