You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@magpie.apache.org by "milamberspace (via GitHub)" <gi...@apache.org> on 2026/08/18 07:20:31 UTC

[PR] fix(tools): scope bridge.groovy config vars with @Field [magpie]

milamberspace opened a new pull request, #1099:
URL: https://github.com/apache/magpie/pull/1099

   ## Summary
   
   - Every `bridge.groovy` subcommand threw `groovy.lang.MissingPropertyException: No such property: TRACKER_URL for class: bridge` before making any HTTP call.
   - Root cause: the script-level config vars (`ENV`, `TRACKER_URL`, `API_TOKEN`, `AUTH_SCHEME`) were declared with a bare top-level `def`. In a Groovy script that makes them locals of the generated `run()` method, so the `cmd_*` methods and the `httpGet`/`httpPost` helpers — compiled onto the script class — cannot see them. The `if (!TRACKER_URL)` guard passed because it runs inside `run()`, masking the bug until a method was entered.
   - Fix: annotate them with `@groovy.transform.Field` (via `import groovy.transform.Field`) so they become fields visible to every method. Added a short comment explaining the `@Field` requirement.
   
   ## Type of change
   
   - [x] Groovy reference impl
   
   ## Test plan
   
   - [x] `prek run --all-files` passes — including `pytest (workspace)`, which runs `tools/jira/tests/test_bridge_write.py` (the suite that was failing before this change).
   - [x] For Groovy bridges touched: command-line invocation tested end-to-end — `groovy tools/jira/bridge.groovy search 'project = FOO'` now reaches the HTTP layer instead of throwing `MissingPropertyException`; the missing-`ISSUE_TRACKER_URL` guard still exits 2.
   
   Before:
   
   ```
   Caught: groovy.lang.MissingPropertyException: No such property: TRACKER_URL for class: bridge
   	at bridge.cmd_search(bridge.groovy:182)
   ```
   
   After: 28 passed in `tools/jira/tests/test_bridge_write.py`.
   
   ## RFC-AI-0004 compliance
   
   - **Write-access discipline** — unchanged; the bridge still only executes confirmed mutations, this fix only makes existing config resolution work. No other principles touched.
   
   ## Linked issues
   
   Closes #1098
   
   ## Notes for reviewers (optional)
   
   - `PROJECT_KEY` is promoted to `@Field` too for consistency, though it is currently dead code (defined, never read) — no runtime impact either way.
   - The other Groovy tool, `tools/dashboard-generator/reference.groovy`, is not affected: it defines no methods (linear script + closures, which capture the script scope) and reads no environment variables.
   


-- 
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: commits-unsubscribe@magpie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(tools): scope bridge.groovy config vars with @Field [magpie]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #1099:
URL: https://github.com/apache/magpie/pull/1099


-- 
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: commits-unsubscribe@magpie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org