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: HTTP check fails when http content is too large with "Body: Error: bufio.Scanner: token too long" #580

Closed
rmetzler opened this issue Apr 28, 2020 · 4 comments · Fixed by #583
Labels

Comments

@rmetzler
Copy link

rmetzler commented Apr 28, 2020

Describe the bug

I have some very big XMLs I need to verify

  • the HTTP status code is 200
  • it starts with the xml declaration

How To Reproduce

http:

  https://example.com/sitemap_0.xml:
    status: 200
    allow-insecure: false
    no-follow-redirects: false
    timeout: 5000

    # all documents should return XML with example.com in it
    body:
      - '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'

Expected Behavior

goss should say this is ok

Actual Behavior

$ goss -gossfile=src/goss/sitemap/bug.yaml v --format=documentation
HTTP: https://example.com/sitemap_0.xml: status: matches expectation: [200]
https://example.com/sitemap_0.xml: Body: Error: bufio.Scanner: token too long


Failures/Skipped:

https://example.com/sitemap_0.xml: Body: Error: bufio.Scanner: token too long

Total Duration: 0.582s
Count: 2, Failed: 1, Skipped: 0

Environment:

  • Version of goss: 7b6cd89
  • OS/Distribution version: I build and run on MacOS
@rmetzler rmetzler added the bug label Apr 28, 2020
@aelsabbahy
Copy link
Member

aelsabbahy commented Apr 28, 2020

Since you're compiling locally, can you try making the following change:
https://github.com/aelsabbahy/goss/blob/master/resource/validate.go#L29

Change that line to:

	maxScanTokenSize = 10240 * 1024

If that works for you, feel free to submit a PR. I don't think a 10mb token size is too unreasonable.

@rmetzler
Copy link
Author

hmm... this feels like a cheap workaround. It will probably do for now, but I hope to find time fixing this properly.

@aelsabbahy
Copy link
Member

Sure, I'd love your thoughts on the proper fix.

@aelsabbahy
Copy link
Member

Feel free to open up a new ticket with a proper fix. I'm guessing it would use bufio.Reader:
https://golang.org/pkg/bufio/#Scanner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants