Commit d37bc2c
fix(runner,backend,control-plane): workflow dir creation + jira-write flag propagation (#1702)
## Summary
Three related bugs fixed across the runner, backend, and
ambient-control-plane.
---
### Bug 1 — Custom workflow fails to load when `/workspace/workflows`
doesn't exist (fixes #1493)
**Root cause — `workflow.py`**
`clone_workflow_at_runtime` called `shutil.move(temp_dir,
workflow_final)` without first creating `workflow_final.parent`
(`/workspace/workflows`). If no prior workflow had been cloned in this
session the directory did not exist, causing a `FileNotFoundError`
silently swallowed by the outer `try/except`. The workflow appeared to
load but nothing was placed in the session context.
The same missing `mkdir` was present in the *subpath-not-found* fallback
path.
**Fix:** add `workflow_final.parent.mkdir(parents=True, exist_ok=True)`
before both `shutil.move` callsites.
**Root cause — `hydrate.sh`** (init-container)
Identical gap in the shell script. The *subpath-found* path already ran
`mkdir -p "$(dirname "$WORKFLOW_FINAL")"` but the no-subpath path and
the subpath-not-found fallback both called `mv` without creating the
parent first, silently failing under `set +e`.
**Fix:** add `mkdir -p` before `mv` in both shell paths.
---
### Bug 2 — Intermittent jira-write failure in backend/operator path
(fixes #1506)
**Root cause**
`getWorkspaceOverrides` was called with `reqK8s` (the **user's** bearer
token) rather than `K8sClient` (the backend service account). End-users
may not have `configmaps.get` permission in the project namespace,
causing the lookup to fail intermittently. When it failed the code fell
back to the global Unleash flag; if `jira-write` was only
workspace-enabled (not globally enabled in Unleash) the fallback
returned `false` and `JIRA_READ_ONLY_MODE` was never set to `"false"`,
so `mcp-atlassian` started in read-only mode and write tools
(`jira_add_comment`, etc.) were absent.
**Fix:** switch to `K8sClient` (backend SA) for the ConfigMap read — the
SA has the necessary permissions and this is a server-side concern.
---
### Bug 3 — `JIRA_READ_ONLY_MODE` never reached Jira credential sidecar
in control-plane path (fixes #1506)
**Root cause**
In the ambient-control-plane deployment, Jira credentials are served by
a dedicated sidecar container that runs `uvx mcp-atlassian`.
`JIRA_READ_ONLY_MODE` was injected into the **runner** container's env
but `buildCredentialSidecars` built each sidecar's env independently and
never received this variable. As a result `mcp-atlassian` always started
in read-only mode regardless of the `jira-write` flag.
**Fix:**
- Add `parseSessionEnvVars()` to deserialise the JSON-encoded
`EnvironmentVariables` field from the Session SDK type.
- Thread `sessionEnvVars` through to `buildCredentialSidecars`.
- Inject `JIRA_READ_ONLY_MODE` into the Jira sidecar env when present —
and **only** for the Jira sidecar (GitHub/K8s/Google sidecars are
unaffected).
---
## Files changed
| File | Change |
|------|--------|
|
`components/runners/ambient-runner/ambient_runner/endpoints/workflow.py`
| Add `mkdir` before `shutil.move` (2 callsites) |
| `components/runners/state-sync/hydrate.sh` | Add `mkdir -p` before
`mv` (2 callsites) |
| `components/backend/handlers/sessions.go` | Use `K8sClient` instead of
`reqK8s` for ConfigMap read |
|
`components/ambient-control-plane/internal/reconciler/kube_reconciler.go`
| Add `parseSessionEnvVars`, propagate `JIRA_READ_ONLY_MODE` to Jira
sidecar |
|
`components/ambient-control-plane/internal/reconciler/kube_reconciler_test.go`
| Update existing tests; add 7 new tests |
| `components/runners/ambient-runner/tests/test_workflow_endpoint.py` |
New: 5 tests for `clone_workflow_at_runtime` |
## Testing
- **Go tests:** `cd components/ambient-control-plane && go test
./internal/reconciler/...`
- **Python tests:** `cd components/runners/ambient-runner && python -m
pytest tests/test_workflow_endpoint.py -v`
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Added support for Jira read-only mode configuration in credential
handling.
* **Bug Fixes**
* Resolved workflow cloning failures when parent directories don't
exist.
* Improved reliability of feature flag override lookups by eliminating
permission-related intermittent failures.
* **Tests**
* Added comprehensive test coverage for Jira read-only mode propagation.
* Added unit tests for workflow endpoint cloning behavior and edge
cases.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: goose <goose@aaif.ai>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>1 parent c700008 commit d37bc2c
6 files changed
Lines changed: 398 additions & 9 deletions
File tree
- components
- ambient-control-plane/internal/reconciler
- backend/handlers
- runners
- ambient-runner
- ambient_runner/endpoints
- tests
- state-sync
Lines changed: 28 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
584 | 584 | | |
585 | 585 | | |
586 | 586 | | |
587 | | - | |
| 587 | + | |
| 588 | + | |
588 | 589 | | |
589 | 590 | | |
590 | 591 | | |
| |||
1193 | 1194 | | |
1194 | 1195 | | |
1195 | 1196 | | |
1196 | | - | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
1197 | 1212 | | |
1198 | 1213 | | |
1199 | 1214 | | |
| |||
1242 | 1257 | | |
1243 | 1258 | | |
1244 | 1259 | | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
1245 | 1271 | | |
1246 | 1272 | | |
1247 | 1273 | | |
| |||
Lines changed: 162 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | | - | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
22 | | - | |
| 25 | + | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
| |||
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
43 | | - | |
| 46 | + | |
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
| |||
97 | 100 | | |
98 | 101 | | |
99 | 102 | | |
100 | | - | |
| 103 | + | |
101 | 104 | | |
102 | 105 | | |
103 | 106 | | |
| |||
124 | 127 | | |
125 | 128 | | |
126 | 129 | | |
127 | | - | |
| 130 | + | |
128 | 131 | | |
129 | 132 | | |
130 | 133 | | |
| |||
143 | 146 | | |
144 | 147 | | |
145 | 148 | | |
146 | | - | |
| 149 | + | |
147 | 150 | | |
148 | 151 | | |
149 | 152 | | |
| |||
176 | 179 | | |
177 | 180 | | |
178 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
984 | 984 | | |
985 | 985 | | |
986 | 986 | | |
987 | | - | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
988 | 991 | | |
989 | 992 | | |
990 | 993 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
152 | 153 | | |
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
| 157 | + | |
156 | 158 | | |
157 | 159 | | |
158 | 160 | | |
| |||
0 commit comments