Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error field of simulator output is an empty object #292

Open
1 task done
richardmarshall opened this issue Apr 3, 2024 · 0 comments
Open
1 task done

[BUG] Error field of simulator output is an empty object #292

richardmarshall opened this issue Apr 3, 2024 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@richardmarshall
Copy link
Collaborator

Kind of proposals

  • Simulator

Describe the problem

When there is an interpreter error while handling a request in the simulator the error information is not properly marshaled to json.

VCL code that cause the problem / reproduceable

acl foo {}

sub vcl_recv {
  if ("aoeu" ~ foo) {
    esi;
  }
}
Request Incoming =========>
[RuntimeException] Left String type could not be a literal in main.vcl at line: 4, position: 14
<========= Request finished
% curl http://127.0.0.1:3124                                                                     
{
  "flows": [
    {
      "file": "main.vcl",
      "line": 3,
      "position": 1,
      "subroutine": "vcl_recv",
      "req": {
        "method": "GET",
        "url": "/",
        "headers": {
          "accept": "*/*",
          "host": "127.0.0.1:3124",
          "user-agent": "curl/8.4.0"
        }
      },
      "backend": ""
    }
  ],
  "logs": [],
  "restarts": 0,
  "backend": "",
  "cached": false,
  "elapsed_time_us": 119,
  "elapsed_time_ms": 0,
  "error": {}, <-- error field is just an empty object
  "client_response": {
    "status_code": 0,
    "body_bytes": 0,
    "headers": {},
    "body": ""
  }
}

Expected behavior

Error field in simulator output should contain the actual error message.

Cause

This is happening because the simulator output struct Error field is the type error. The go builtin error type does not implement json.Marshaler and does not have any public fields so the resulting json output is an empty object.

@richardmarshall richardmarshall added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers labels Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant