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

Allowed breadcrumbs to accept empty string #427

Merged
merged 7 commits into from
Feb 20, 2018

Conversation

Cawllec
Copy link
Contributor

@Cawllec Cawllec commented Dec 5, 2017

Fixes #426
This fix allows breadcrumbs to accept an empty string as a valid name argument, similar to reports accepting an empty string as a valid name parameter.

@GrahamCampbell
Copy link
Contributor

👎 I don't think this is a good idea. Instead, for errors that are empty, don't attempt to leave a breadcrumb.

@Cawllec
Copy link
Contributor Author

Cawllec commented Dec 5, 2017

I think it's a good idea to be able to track when errors/events have occurred previously even if they don't have definitive names.

@GrahamCampbell
Copy link
Contributor

I'll send an alternative PR when I can find some time. Potentially on Tuesday. :)

@jmshal
Copy link
Contributor

jmshal commented Dec 8, 2017

Presumably the notifier will catch and notify the exception so the developer is aware of the invalid breadcrumb - rather than silently ignoring it? If the empty breadcrumb was a totally valid mistake on the developer's side, not adding the breadcrumb to any potential future report could be misleading/confusing when trying to track back the breadcrumbs? Idk, just my 2 cents.

Edit: I'm dumb - I understand the PR now xD

🏃

Copy link
Contributor

@kattrali kattrali left a comment

Choose a reason for hiding this comment

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

Rather than accepting empty names, if we have an empty-named report, the breadcrumb should express it.

(Error reported using NULL)

or similar. That way we expose context that the user likely doesn't realize.

@GrahamCampbell
Copy link
Contributor

My alternative PR is still coming. I really don't like the idea of silently allowing breadcrumbs without content.

@Cawllec
Copy link
Contributor Author

Cawllec commented Dec 21, 2017

I think having breadcrumbs without names in the dashboard will be better than not, as it's still contextual Bugsnag data that will let people track down potential issues in their Bugsnag usage, located in Bugsnag.

}

if ($name === '') {
$name = 'NULL name given';
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not true. null !== ''. In fact, this won't fix the issue for the person who was passing null, since is_string(null) === false.

@Cawllec
Copy link
Contributor Author

Cawllec commented Jan 10, 2018

Can we revisit this and try to get it completed?

@GrahamCampbell
Copy link
Contributor

Yeh, sorry. Been really busy. Will look at it on Friday.

Copy link
Contributor

@kattrali kattrali left a comment

Choose a reason for hiding this comment

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

This general approach makes sense. The benefits of delivering the breadcrumb are

  1. to be consistent about the automatic behavior of breadcrumbs, like maintaining an accurate list of errors sent to Bugsnag,
  2. to surface otherwise invisible issues in configuration which would otherwise be silenced or buried in debug logs, and
  3. to deliver any metadata added to breadcrumbs which could provide debugging assistance. Some errors can be surfaced by breadcrumb type and metadata alone.

All that said, I thought a bit about this interface and how we could make it easier to parse when delivering otherwise broken breadcrumbs. I put in some inline comments for a preferred interface which can close this issue out.

throw new InvalidArgumentException('The breadcrumb name must be a non-empty string.');
if (!is_string($name)) {
if (is_null($name)) {
$name = 'NULL breadcrumb name given';
Copy link
Contributor

Choose a reason for hiding this comment

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

All of these cases can be condensed to the same name, "<no name>" with a validation error in the breadcrumb metadata to indicate a configuration issue. That way, the presentation is consistent and any future interface to searching/filtering breadcrumbs can aggregate on a single name value or breadcrumbs with a BreadcrumbError, etc.

  • Breadcrumb name is null?
    • <no name> - ['BreadcrumbError' => 'NULL provided as the breadcrumb name']
  • Breadcrumb name is empty?
    • <no name> - ['BreadcrumbError' => 'Empty string provided as the breadcrumb name']
  • Breadcrumb name is not a string?
    • <no name> - ['BreadcrumbError' => 'Breadcrumb name must be a string - "Integer" provided instead']

@GrahamCampbell
Copy link
Contributor

I'd still rather this raised an error if you provide an empty description, and just the exception recording case made sure that it doesn't provide an empty description.

@GrahamCampbell
Copy link
Contributor

Gonna prep that PR right now. Been meaning to do it all month.

@GrahamCampbell
Copy link
Contributor

GrahamCampbell commented Jan 29, 2018

The problem really lies with the fact that this:

    /**
     * Get the error name.
     *
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

in the report object can return empty string or null.

@GrahamCampbell
Copy link
Contributor

Ok, what do you make of #463. :)

@kattrali kattrali merged commit 7200df3 into master Feb 20, 2018
@kattrali kattrali deleted the cawllec/empty-breadcrumb-name branch February 20, 2018 14:51
@kattrali
Copy link
Contributor

Decided to do both - this change allows for creating breadcrumbs with no name and appends in error message in that case, and the other change sets a sensible Report name in the case that no name is set.

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

Successfully merging this pull request may close these issues.

Error: The breadcrumb name must be a non-empty string.
4 participants