Comments (3)
Hi @bwaz, can you show (exactly) how you're calling the API?
If you're using cURL with the -d
then the module may not be encoded as you expect. From the cURL man page:
If you start the data with the letter @, the rest should be a file name to read the data from, or - if you want
curl to read the data from stdin. Multiple files can also be specified. Posting data from a file named 'foobar'
would thus be done with --data @foobar. When --data is told to read from a file like that, carriage returns and
newlines will be stripped out. If you don't want the @ character to have a special interpretation use --data-raw
instead.
E.g., if you run curl -d @somefile.rego localhost:8181/v1/policies/opaexample -X PUT
(where somefile.rego contains the failing example above) the request message body will be:
0x0040: 4876 e85d 4876 e85d 5055 5420 2f76 312f Hv.]Hv.]PUT./v1/
0x0050: 706f 6c69 6369 6573 2f74 6573 7420 4854 policies/test.HT
0x0060: 5450 2f31 2e31 0d0a 486f 7374 3a20 6c6f TP/1.1..Host:.lo
0x0070: 6361 6c68 6f73 743a 3831 3831 0d0a 5573 calhost:8181..Us
0x0080: 6572 2d41 6765 6e74 3a20 6375 726c 2f37 er-Agent:.curl/7
0x0090: 2e35 312e 300d 0a41 6363 6570 743a 202a .51.0..Accept:.*
0x00a0: 2f2a 0d0a 436f 6e74 656e 742d 4c65 6e67 /*..Content-Leng
0x00b0: 7468 3a20 3434 0d0a 436f 6e74 656e 742d th:.44..Content-
0x00c0: 5479 7065 3a20 6170 706c 6963 6174 696f Type:.applicatio
0x00d0: 6e2f 782d 7777 772d 666f 726d 2d75 726c n/x-www-form-url
0x00e0: 656e 636f 6465 640d 0a0d 0a70 6163 6b61 encoded....packa
0x00f0: 6765 206f 7061 2e65 7861 6d70 6c65 7369 ge.opa.examplesi
0x0100: 6d70 6f72 7420 7265 7175 6573 742e 6578 mport.request.ex
0x0110: 616d 706c 652e 61 ample.a
Notice the whitespace between the package directive and import directive has been dropped.
If you are using cURL, I recommend the --data-binary
instead of -d/--data
. Perhaps the docs should be updated to include a note about this.
from opa.
I'm calling like this:
curl -X PUT -H 'Content-Type: text/plain' http://localhost:8181/v1/policies/opaexample -d@opaexample
from opa.
OK, I will update the docs to include a note about this. Thanks for filing the issue!
from opa.
Related Issues (20)
- `opa inspect` failure on custom funcs in policies HOT 4
- Customizable GOFLAGS HOT 2
- Add `--v1-compatible` flag to more commands HOT 1
- OPA fmt in OPA 0.58+ improperly stripping assignment and term from chained rules HOT 1
- rego-v1: Document and report on alternatives to calls to deprecated built-ins
- Issue with Custom OPA Storage implementation HOT 7
- Improve `rego_type_error` error message
- Partial sets can be O(nĀ²) when accessed iteratively
- Incoherent result of opa compile response HOT 8
- Unable to distinguish between bool and string in sprintf HOT 7
- Support raising builtin errors for test runner
- Follow symlinks when building bundles HOT 4
- PE: allow adjusting which non-deterministic builtins are to be evaluated HOT 1
- Add out-of-the-box zap logger HOT 3
- Introduce PURL built-in functions HOT 4
- Using `if` keyword in rule declaration makes the AST rule name empty HOT 3
- OPA process OOM when a bundle contains a large file despite having size_limit_bytes HOT 7
- [opa-envoy-plugin] Decision Id in check response HOT 5
- Add `--v1-compatible` flag to remaining commands
- Json Schema: `opa eval` throws cryptic error when a `$ref` tag is used inside `allOf` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opa.