zoncoen / scenarigo

An end-to-end scenario testing tool for HTTP/gRPC server.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unmarshalizing Fails After Line Comments

0xys opened this issue · comments

commented

Relevant Version

  • the latest HEAD on main branch.
    • No issue on the tagged latest v0.14.2.

Symptom

The scenario with comments like below fails to unmarshal the yaml file.

Given the scenario like:

title: get scenarigo repository
steps:
- title: expect 404
  protocol: http
  request:
    method: GET
    url: "https://api.github.com/repos/zoncoen/aaaaaaaaaaaaa"
    body:
      # message: this comment does evil
  expect:
    code: Not Found

Here is the error,

/Users/username/code/repo/scenarigo/.bin/scenarigo run
--- FAIL: scenario/github.yaml (0.40s)
    --- FAIL: scenario/github.yaml/get_scenarigo_repository (0.40s)
        --- FAIL: scenario/github.yaml/get_scenarigo_repository/expect_404 (0.40s)
                request:
                  method: GET
                  url: https://api.github.com/repos/zoncoen/aaaaaaaaaaaaa
                  header:
                    User-Agent:
                    - scenarigo/v0.14.2-dev
                response:
                  header:
                    Access-Control-Allow-Origin:
                    - "*"
                    Access-Control-Expose-Headers:
                    - ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset
                    Content-Encoding:
                    - gzip
                    Content-Length:
                    - "112"
                    Content-Security-Policy:
                    - default-src 'none'
                    Content-Type:
                    - application/json; charset=utf-8
                    Date:
                    - Thu, 01 Jun 2023 05:41:32 GMT
                    Referrer-Policy:
                    - origin-when-cross-origin, strict-origin-when-cross-origin
                    Server:
                    - GitHub.com
                    Strict-Transport-Security:
                    - max-age=31536000; includeSubdomains; preload
                    Vary:
                    - Accept-Encoding, Accept, X-Requested-With
                    X-Content-Type-Options:
                    - nosniff
                    X-Frame-Options:
                    - deny
                    X-Github-Api-Version-Selected:
                    - 2022-11-28
                    X-Github-Media-Type:
                    - github.v3; format=json
                    X-Github-Request-Id:
                    - 0505:0BE5:DBA2D8:E77D3C:64782F8C
                    X-Ratelimit-Limit:
                    - "60"
                    X-Ratelimit-Remaining:
                    - "48"
                    X-Ratelimit-Reset:
                    - "1685599002"
                    X-Ratelimit-Resource:
                    - core
                    X-Ratelimit-Used:
                    - "12"
                    X-Xss-Protection:
                    - "0"
                  body:
                    documentation_url: "https://docs.github.com/rest/reference/repos#get-a-repository"
                    message: Not Found
                elapsed time: 0.401880 sec
                .steps[0].expect.code: expected 200 but got Not Found
FAIL
FAIL	scenario/github.yaml	0.403s
FAIL

Scenario fails with expected 200, where 200 is a default code, indicating that the lines after the comment (# message: this comment does evil) are dropped somehow.

Thanks for your report!
I suppose the root cause is a dependent module bug, but I have added a workaround for now.