Skip to content

contrib/data_filter_mongo example test case for employees/john example not working as advertised in README.md (returns empty) #215

Open
@wvkehoe

Description

@wvkehoe

Hello @VineethReddy02

Thank you for making the data_filter_mongo contribution to OPA.

Can you provide the current status of this contribution?

When I attempt to run the employees/john example that you describe in https://github.com/open-policy-agent/contrib/blob/main/data_filter_mongodb/README.md, I get an empty 200 response (see my command line below).

Note that since I'm running on an M1 Mac and I could not find a M1 arch published version of vineeth97/opa-mongo, I needed t build from source. Also, i noticed that the code as provided reads a request body on the GET endpoint which, since I'm using curl to send requests, meant that I needed to add a POST endpoint that uses the same api.handleGetReq handler. I've tried to trace down through the debugger to pinpoint where things go wrong but this is complicated by the extremely nested nature of the evaluation. The best I've been able to determine so far is that the "defined" boolean at https://github.com/open-policy-agent/opa/blob/main/topdown/eval.go#L417 never gets set to true for any evaluated step executed by evalStep method so the method returns nil.

The only output I see is in the following, one-line log output message from the server log:

{"level":"info","ts":1681043557.8948538,"caller":"opa/opa.go:62","msg":"received request","request":{"method":"POST","path":["employees","john"],"user":"danerys"}}

Upgrading the opa dependency from 0.43.1 to latest 0.51.0 does not help matters.

Any suggestions would be appreciated.

Here is my command line I'm using to transmit the request to the server:

@curl -X POST http://localhost:9095/employees/john -d @- <<EOF

{
"input": {
"method": "GET",
"path": ["employees", "john"],
"user": "danerys"
}
}
EOF

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions