Commit 02757d6
fix(backend): resolve marketplace agent access in get_graph_execution endpoint (#11396)
## Summary
Fixes critical issue where `GET
/graphs/{graph_id}/executions/{graph_exec_id}` failed for marketplace
agents with "Graph not found" errors due to incorrect version access
checking.
## Root Cause
The endpoint was checking access to the **latest version** of a graph
instead of the **specific version used in the execution**. This broke
marketplace agents when:
1. User executes a marketplace agent (e.g., v3)
2. Graph owner later publishes a new version (e.g., v4)
3. User tries to view execution details
4. **BUG**: Code checked access to latest version (v4) instead of
execution version (v3)
5. If v4 wasn't published to marketplace → access denied → "Graph not
found"
## Original Problematic Code
```python
# routers/v1.py - get_graph_execution (WRONG ORDER)
graph = await graph_db.get_graph(graph_id=graph_id, user_id=user_id) # ❌ Uses LATEST version
if not graph:
raise HTTPException(404, f"Graph #{graph_id} not found")
result = await execution_db.get_graph_execution(...) # Gets execution data
```
## Solution
**Reordered operations** to check access against the **execution's
specific version**:
```python
# NEW CODE (CORRECT ORDER)
result = await execution_db.get_graph_execution(...) # ✅ Get execution FIRST
if not await graph_db.get_graph(
graph_id=result.graph_id,
version=result.graph_version, # ✅ Use execution's version, not latest!
user_id=user_id,
):
raise HTTPException(404, f"Graph #{graph_id} not found")
```
### Key Changes Made
1. **Fixed version access logic** (routers/v1.py:1075-1095):
- Reordered operations to get execution data first
- Check access using `result.graph_version` instead of latest version
- Applied same fix to external API routes
2. **Enhanced `get_graph()` marketplace fallback**
(data/graph.py:919-935):
- Added proper marketplace lookup when user doesn't own the graph
- Supports version-specific marketplace access checking
- Maintains security by only allowing approved, non-deleted listings
3. **Activity status generator fix**
(activity_status_generator.py:139-144):
- Use `skip_access_check=True` for internal system operations
4. **Missing block handling** (data/graph.py:94-103):
- Added `_UnknownBlockBase` placeholder for graceful handling of deleted
blocks
## Example Scenario Fixed
1. **User**: Installs marketplace agent "Blog Writer" v3
2. **Owner**: Later publishes v4 (not to marketplace yet)
3. **User**: Runs the agent (executes v3)
4. **Before**: Viewing execution details fails because code checked v4
access
5. **After**: ✅ Viewing execution details works because code checks v3
access
## Impact
- ✅ **Marketplace agents work correctly**: Users can view execution
details for any marketplace agent version they've used
- ✅ **Backward compatibility**: Existing owned graphs continue working
- ✅ **Security maintained**: Only allows access to versions user
legitimately executed
- ✅ **Version-aware access control**: Proper access checking for
specific versions, not just latest
## Testing
- [x] Marketplace agents: Execution details now accessible for all
executed versions
- [x] Owned graphs: Continue working as before
- [x] Version scenarios: Access control works correctly for specific
versions
- [x] Missing blocks: Graceful handling without errors
**Root issue resolved**: Version mismatch between execution version and
access check version that was breaking marketplace agent execution
viewing.
---------
Co-authored-by: Claude <[email protected]>1 parent 2569576 commit 02757d6
File tree
7 files changed
+74
-33
lines changed- autogpt_platform/backend/backend
- data
- executor
- server
- external/routes
- routers
- v2
- otto
- store
7 files changed
+74
-33
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
884 | 885 | | |
885 | 886 | | |
886 | 887 | | |
887 | | - | |
| 888 | + | |
| 889 | + | |
888 | 890 | | |
889 | | - | |
890 | 891 | | |
891 | 892 | | |
892 | 893 | | |
| |||
897 | 898 | | |
898 | 899 | | |
899 | 900 | | |
900 | | - | |
901 | | - | |
902 | | - | |
| 901 | + | |
903 | 902 | | |
904 | | - | |
905 | | - | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
906 | 912 | | |
907 | | - | |
908 | | - | |
909 | | - | |
910 | | - | |
911 | | - | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
912 | 920 | | |
913 | | - | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
914 | 928 | | |
915 | | - | |
916 | | - | |
917 | | - | |
918 | | - | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
919 | 938 | | |
920 | 939 | | |
921 | 940 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
140 | 145 | | |
141 | 146 | | |
142 | 147 | | |
| |||
Lines changed: 7 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | 109 | | |
114 | 110 | | |
115 | 111 | | |
| |||
120 | 116 | | |
121 | 117 | | |
122 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
123 | 126 | | |
124 | 127 | | |
125 | 128 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
803 | 803 | | |
804 | 804 | | |
805 | 805 | | |
806 | | - | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
807 | 809 | | |
808 | 810 | | |
809 | 811 | | |
| |||
883 | 885 | | |
884 | 886 | | |
885 | 887 | | |
886 | | - | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
887 | 893 | | |
888 | 894 | | |
889 | 895 | | |
| |||
1069 | 1075 | | |
1070 | 1076 | | |
1071 | 1077 | | |
1072 | | - | |
1073 | | - | |
1074 | | - | |
1075 | | - | |
1076 | | - | |
1077 | | - | |
1078 | 1078 | | |
1079 | 1079 | | |
1080 | 1080 | | |
1081 | | - | |
| 1081 | + | |
1082 | 1082 | | |
1083 | 1083 | | |
1084 | 1084 | | |
1085 | 1085 | | |
1086 | 1086 | | |
1087 | 1087 | | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
1088 | 1097 | | |
1089 | 1098 | | |
1090 | 1099 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1343 | 1343 | | |
1344 | 1344 | | |
1345 | 1345 | | |
| 1346 | + | |
1346 | 1347 | | |
1347 | 1348 | | |
1348 | 1349 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
542 | 542 | | |
543 | 543 | | |
544 | 544 | | |
545 | | - | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
546 | 548 | | |
547 | 549 | | |
548 | 550 | | |
| |||
0 commit comments