Skip to content

Avoid NullReferenceException on 401 Unauthorized#2561

Merged
stevejgordon merged 2 commits into
elastic:mainfrom
monty241:patch-1
Aug 12, 2025
Merged

Avoid NullReferenceException on 401 Unauthorized#2561
stevejgordon merged 2 commits into
elastic:mainfrom
monty241:patch-1

Conversation

@monty241
Copy link
Copy Markdown
Contributor

@monty241 monty241 commented Mar 4, 2025

We frequently experience NullReferenceExceptions in our logging registered by the first chance exception handler.

It is caused by intakeResponse being not null: Accepted = 0, Errors = null, and then evaluating intakeResponse.Errors.Count triggering an error.

Environment:

Unauthorized 401 on https://53b082e7cfeb4d9a9c117371xxxxxxxx.apm.eu-west-1.aws.cloud.es.io/intake/v2/events

The payload returned is:

{"error":"authentication failed"}\n

So an improvement might be to also deserialize this JSON format.

We frequently experience NullReferenceExceptions in our logging registered by the first chance exception handler.

It is caused by `intakeResponse` being not null: Accepted = 0, Errors = null, and then evaluating `intakeResponse.Errors.Count` triggering an error.

Environment:

Unauthorized 401 on https://53b082e7cfeb4d9a9c117371xxxxxxxx.apm.eu-west-1.aws.cloud.es.io/intake/v2/events

The payload returned is:

```json
{"error":"authentication failed"}\n
```

So an improvement might be to also deserialize this JSON format.
@cla-checker-service
Copy link
Copy Markdown

cla-checker-service Bot commented Mar 4, 2025

💚 CLA has been signed

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 4, 2025

👋 @monty241 Thanks a lot for your contribution!

It may take some time before we review a PR, so even if you don’t see activity for some time, it does not mean that we have forgotten about it.

Every once in a while we go through a process of prioritization, after which we are focussing on the tasks that were planned for the upcoming milestone. The prioritization status is typically reflected through the PR labels. It could be pending triage, a candidate for a future milestone, or have a target milestone set to it.

@monty241
Copy link
Copy Markdown
Contributor Author

monty241 commented Mar 4, 2025

❌ Author of the following commits did not sign a Contributor Agreement: 9a5ba81

Please, read and sign the above mentioned agreement if you want to contribute to this project

Signed twice now, but the site seems broken (apps.docusign.com heeft de verbinding geweigerd.):

image

stevejgordon
stevejgordon previously approved these changes Mar 13, 2025
Copy link
Copy Markdown
Contributor

@stevejgordon stevejgordon left a comment

Choose a reason for hiding this comment

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

Thanks for finding this and submitting the fix.

@stevejgordon
Copy link
Copy Markdown
Contributor

run docs-build

Copy link
Copy Markdown
Contributor

@JeremyBessonElastic JeremyBessonElastic left a comment

Choose a reason for hiding this comment

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

LGTM

Remark:
It should be enough:
if (intakeResponse?.Errors?.Count > 0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants