Skip to content

Log.prototype[severity] functions cannot deal with circular references#1983

Merged
stephenplusplus merged 4 commits intogoogleapis:masterfrom
ofrobots:logging-cicular
Mar 3, 2017
Merged

Log.prototype[severity] functions cannot deal with circular references#1983
stephenplusplus merged 4 commits intogoogleapis:masterfrom
ofrobots:logging-cicular

Conversation

@ofrobots
Copy link
Contributor

@ofrobots ofrobots commented Feb 10, 2017

Right now the PR adds a test that shows this. What are your thoughts on the fix? The simplest fix would be to fix Log.assignSeverityToEntries_ but am concerned that the problem may exist in other places too.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Feb 10, 2017
@stephenplusplus
Copy link
Contributor

We chose to throw the error instead of hiding it and removing part of the user's object. My thoughts on that were explained in this issue. Please discuss in that issue if you have reasons that's a bad idea on our part.

1) Logging logs should write a single entry to a log:
     Error: The JSON data for this entry has a circular reference.

@ofrobots
Copy link
Contributor Author

Either we should test with is-circular uniformly, or not test is-circular at all.. Elsewhere in the repo we use is-circular to test for circular objects and report a nice error.

A large stack overflow in extend is not as useful to users.

I think this is a distinct issue.

@stephenplusplus
Copy link
Contributor

We throw a small error as I pasted above. Maybe I'm not seeing what you're seeing. Can you paste the output you're seeing?

@ofrobots
Copy link
Contributor Author

I guess it depends on test ordering. I bypassed some of the tests because the system tests aren't working for me (#1982).

Try mocha system-test/*.js --no-timeouts --bail -g 'logs' with my test.

@stephenplusplus
Copy link
Contributor

Okay, I reproduced. We definitely should check with is-circular the same was we do in Entry#toJSON.

@ofrobots
Copy link
Contributor Author

ofrobots commented Mar 3, 2017

Here's a better fix. @stephenplusplus PTAL.

severity: severity
}
});
var entry = extend(new Entry(), entry);

This comment was marked as spam.

This comment was marked as spam.

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.

@googlebot googlebot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Mar 3, 2017
@stephenplusplus stephenplusplus merged commit 5472412 into googleapis:master Mar 3, 2017
@stephenplusplus
Copy link
Contributor

Cool, thanks!

@ofrobots ofrobots deleted the logging-cicular branch March 3, 2017 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: no This human has *not* signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants