Skip to content

fix: opa - use --stdin-input instead of --input /dev/stdin (Windows) - #3913

Merged
MohammadHaroonAbuomar merged 3 commits into
microsoft:mainfrom
fer-marino:fix/opa-stdin-input-windows
Sep 14, 2026
Merged

MohammadHaroonAbuomar merged 3 commits into
microsoft:mainfrom
fer-marino:fix/opa-stdin-input-windows

Conversation

@fer-marino

@fer-marino Fernando Marino` (fer-marino) commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3912.

OPAEvaluator's local CLI mode constructed opa eval --input /dev/stdin and piped the input JSON via subprocess.run(input=...). /dev/stdin is a real special file on Linux/macOS, so this happened to work there, but it doesn't exist on Windows: every call failed with

opa eval failed: open /dev/stdin: The system cannot find the path specified.

Because _evaluate_opa_cli catches the non-zero opa eval exit and returns OPADecision(allowed=False, ...) rather than raising, this was worse than a crash: every policy check silently came back denied on Windows, including cases that should have been allowed - the project's own test_opa.py demonstrates this precisely, since it asserts allowed=True in several cases.

Confirmed both ways by actually running tests/test_opa.py on Windows with opa v1.20.2 on PATH:

  • Before this change: 10 of 26 tests fail, every one an assert ... allowed is True on a policy that should have matched.
  • After this change: 25 of 26 pass. The one remaining failure (test_evaluation_timing, asserting evaluation_ms < 100) is unrelated to this fix and pre-existing: opa eval's own subprocess-spawn cost is ~550-650ms on this machine regardless of the /dev/stdin bug, so that assertion looks environment-dependent rather than something this change touches.

Fix: opa eval has a dedicated, portable flag for exactly this - -I/--stdin-input, which reads the input document from the process's actual stdin rather than a file path. Swapping to it removes the platform dependency entirely.

Related Issue

If no related issue is linked above, you must complete "Problem & Solution", "Impact on Your Work", and "Alternatives Considered" below.

Problem & Solution

Impact on Your Work

Timeline

Alternatives Considered

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Maintenance (dependency updates, CI/CD, refactoring)
  • Security fix

Package(s) Affected

Core & runtime:

  • agent-governance-toolkit-core
  • agent-primitives
  • agent-os
  • agent-mesh
  • agent-runtime
  • agent-sre
  • agent-compliance

Governance & security:

  • agent-mcp-governance
  • agent-rag-governance
  • agent-sandbox
  • agent-discovery
  • agt-policies
  • policy-engine

Platform & tooling:

  • agent-hypervisor
  • agent-lightning
  • agent-marketplace
  • agent-governance-toolkit-cli
  • agent-governance-toolkit-integrations
  • agent-governance-toolkit-protocols
  • agentmesh-integrations (framework integrations)

CLI plugins:

  • agent-governance CLI plugins (copilot-cli / claude-code / opencode / antigravity-cli)

Shared / other:

  • schemas
  • action (GitHub Action)
  • examples
  • docs / root

Testing

Unit Testing

Manual Testing

Checklist

  • I have linked a related issue above, or completed "Problem & Solution", "Impact on Your Work", and "Alternatives Considered"
  • My code follows the project style guidelines (ruff check)
  • I have added tests that prove my fix/feature works
  • All new and existing tests pass (pytest)
  • I have updated documentation as needed
  • I have signed the Microsoft CLA

Attribution & Prior Art

  • This contribution does not contain code copied or derived from other projects without attribution
  • Any external projects that inspired this design are credited in code comments or documentation
  • If this PR implements functionality similar to an existing open-source project, I have listed it below

Prior art / related projects (if any):

AI Assistance

  • I can explain every meaningful change in this PR: what it does, why, and what tradeoffs were considered
  • I have run tests and verification appropriate for this change
  • No part of this PR was autonomously submitted by an AI agent without my review
  • I have not used AI to generate review comments on others' PRs

If AI tools materially shaped this change, briefly note what was used:

IP, Patents, and Licensing

  • This contribution does not implement patent-pending or patent-encumbered techniques
  • This contribution does not require an NDA or licensing agreement to understand or use
  • Any AI tools used have terms compatible with the MIT License

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions github-actions Bot added agent-mesh agent-mesh package size/S Small PR (< 50 lines) labels Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

PR Review Summary

Check Status Details
🔍 Code Review ⚠️ Missing No current-run comment
🛡️ Security Scan ⚠️ Missing No current-run comment
🔄 Breaking Changes ⚠️ Missing No current-run comment
📝 Docs Sync ⚠️ Missing No current-run comment
🧪 Test Coverage ⚠️ Missing No current-run comment

Verdict: ⚠️ AI review incomplete; ready for human review

AI review comments are untrusted advisory output. The summary reports workflow-generated completion status only, not model-authored pass/fail claims.

@fer-marino Fernando Marino` (fer-marino) changed the title opa: use --stdin-input instead of --input /dev/stdin (fixes Windows) fix: opa - use --stdin-input instead of --input /dev/stdin (Windows) Sep 9, 2026
@fer-marino

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@MohammadHaroonAbuomar MohammadHaroonAbuomar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Commit bc35531 has no Signed-off-by trailer. The DCO check has not run yet because the fork workflows are gated, but it will fail once a maintainer approves them. Please git rebase --signoff and force-push; everything else in this PR is already verified and this is the only remaining item.

OPAEvaluator's local CLI mode constructed `opa eval --input /dev/stdin`
and piped the input JSON via subprocess.run(input=...). /dev/stdin is a
real special file on Linux/macOS, so this happened to work there, but it
doesn't exist on Windows: every call failed with

    opa eval failed: open /dev/stdin: The system cannot find the path specified.

Because _evaluate_opa_cli catches the non-zero opa eval exit and returns
OPADecision(allowed=False, ...) rather than raising, this was worse than
a crash: every policy check silently came back denied on Windows,
including cases that should have been allowed - the project's own
test_opa.py demonstrates this precisely, since it asserts allowed=True
in several cases.

Confirmed both ways by actually running tests/test_opa.py on Windows with
opa v1.20.2 on PATH:
- Before this change: 10 of 26 tests fail, every one an `assert ...
  allowed is True` on a policy that should have matched.
- After this change: 25 of 26 pass. The one remaining failure
  (test_evaluation_timing, asserting evaluation_ms < 100) is unrelated
  to this fix and pre-existing: opa eval's own subprocess-spawn cost is
  ~550-650ms on this machine regardless of the /dev/stdin bug, so that
  assertion looks environment-dependent rather than something this
  change touches.

Fix: opa eval has a dedicated, portable flag for exactly this -
-I/--stdin-input, which reads the input document from the process's
actual stdin rather than a file path. Swapping to it removes the platform
dependency entirely.

Signed-off-by: Fernando Marino <fernando.marino85@gmail.com>
@fer-marino

Copy link
Copy Markdown
Contributor Author

Done - rebased with --signoff and force-pushed (bc35531 -> 36a5827). The commit now carries a Signed-off-by trailer.

San-Hsien (SanHsien) added a commit to SanHsien/agent-governance-toolkit that referenced this pull request Sep 12, 2026
Fernando Marino` (fer-marino) added a commit to fer-marino/agent-governance-toolkit that referenced this pull request Sep 14, 2026
The merge from origin/main silently reintroduced --input /dev/stdin
in _evaluate_opa_cli: main's own version of this function (still
without microsoft#3913, per carloshvp's review comment) matched closely enough
around _rego_file_for_cli() that git took main's flag without
flagging a conflict. Caught by rerunning the test suite post-merge -
25 opa-CLI tests failed with the exact original bug's symptom
(every policy check denied). Restored --stdin-input; full suite
(190 tests) passes again except the known pre-existing timing test.

@MohammadHaroonAbuomar MohammadHaroonAbuomar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified at ea293be: the head is the reviewed 36a5827 patch plus a clean merge of current main (tree matches git merge-tree byte for byte). 26/26 opa tests pass locally against the CI-pinned opa build.

@MohammadHaroonAbuomar
MohammadHaroonAbuomar merged commit 432f839 into microsoft:main Sep 14, 2026
124 checks passed
Yuvraj Singh (yuvrajsingh2428) pushed a commit to yuvrajsingh2428/agent-governance-toolkit that referenced this pull request Oct 1, 2026
…icrosoft#3913)

OPAEvaluator's local CLI mode constructed `opa eval --input /dev/stdin`
and piped the input JSON via subprocess.run(input=...). /dev/stdin is a
real special file on Linux/macOS, so this happened to work there, but it
doesn't exist on Windows: every call failed with

    opa eval failed: open /dev/stdin: The system cannot find the path specified.

Because _evaluate_opa_cli catches the non-zero opa eval exit and returns
OPADecision(allowed=False, ...) rather than raising, this was worse than
a crash: every policy check silently came back denied on Windows,
including cases that should have been allowed - the project's own
test_opa.py demonstrates this precisely, since it asserts allowed=True
in several cases.

Confirmed both ways by actually running tests/test_opa.py on Windows with
opa v1.20.2 on PATH:
- Before this change: 10 of 26 tests fail, every one an `assert ...
  allowed is True` on a policy that should have matched.
- After this change: 25 of 26 pass. The one remaining failure
  (test_evaluation_timing, asserting evaluation_ms < 100) is unrelated
  to this fix and pre-existing: opa eval's own subprocess-spawn cost is
  ~550-650ms on this machine regardless of the /dev/stdin bug, so that
  assertion looks environment-dependent rather than something this
  change touches.

Fix: opa eval has a dedicated, portable flag for exactly this -
-I/--stdin-input, which reads the input document from the process's
actual stdin rather than a file path. Swapping to it removes the platform
dependency entirely.

Signed-off-by: Fernando Marino <fernando.marino85@gmail.com>
Co-authored-by: Fernando Marino <f.marino@rheagroup.com>
Signed-off-by: yuvrajsingh2428 <offcyuvi2428@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-mesh agent-mesh package size/S Small PR (< 50 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OPAEvaluator local CLI mode hard-codes --input /dev/stdin, silently denies every policy check on Windows

2 participants