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

fix: abridge call graph creation error messages in analytics #1279

Merged
merged 1 commit into from
Jul 22, 2020

Conversation

muscar
Copy link
Contributor

@muscar muscar commented Jul 22, 2020

  • Ready for review
  • Follows CONTRIBUTING rules
  • Reviewed by Snyk internal team

What does this PR do?

Since the call graph error messages can get pretty big, abridge them to something more manageable. This keep the beginning, and end of the message since, presumably, that's where the most important details are.

@muscar muscar requested a review from darmalovan July 22, 2020 10:52
@muscar muscar requested review from a team as code owners July 22, 2020 10:52
@ghost ghost requested review from dkontorovskyy and gitphill July 22, 2020 10:52
@github-actions
Copy link
Contributor

github-actions bot commented Jul 22, 2020

Expected release notes (by @muscar)

fixes:
abridge call graph creation error messages in analytics (7a68ad3)

  • I hereby acknowledge these release notes are 🥙 AWESOME 🥙

Copy link
Contributor

@dkontorovskyy dkontorovskyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@jasiskis jasiskis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

return msg;
}
const e = ellipsis || ' ... ';
const toKeep = (maxLen - e.length) / 2;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think toKeep can be a not whole number

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know. But it seems to round it when used in slice.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to round it before, less JS magic

if (msg.length <= maxLen) {
return msg;
}
const e = ellipsis || ' ... ';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe have it as an optional param on line 4?
ellipsis = '...': string,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that supported by TypeScript?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional parameters? in JS and TS

analytics.add('callGraphError', err.innerError.toString());
analytics.add(
'callGraphError',
abridgeErrorMessage(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go also to the test file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing that method would be quite involved, and the functional tests for abridging the string should cover a reasonable number of cases.

analytics.add('callGraphError', err.innerError.toString());
analytics.add(
'callGraphError',
abridgeErrorMessage(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be nice to say why we are doing this trimming with a comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is pretty self-explanatory from the code, no? E.g. ANALYTICS_PAYLOAD_MAX_LENGTH

@muscar muscar merged commit 6f3ec4f into master Jul 22, 2020
@muscar muscar deleted the fix/abridge-call-graph-error-message branch July 22, 2020 12:11
@snyksec
Copy link

snyksec commented Jul 22, 2020

🎉 This PR is included in version 1.364.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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 this pull request may close these issues.

5 participants