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

ApplicationInsights:Could not decode the auth cookie with error #1404

Open
DevRCRun opened this issue Dec 11, 2024 · 1 comment
Open

ApplicationInsights:Could not decode the auth cookie with error #1404

DevRCRun opened this issue Dec 11, 2024 · 1 comment

Comments

@DevRCRun
Copy link

DevRCRun commented Dec 11, 2024

SDK Version: 2.9.6
Express version: 4.21.1

The above version of the SDK is in use with an Express application, installed on Windows Server.

ApplicationInsights:Could not decode the auth cookie with error: [
"[object Error]{ stack: 'URIError: URI malformed\n" +
' at decodeURI ()\n' +
' at HttpRequestParser._getId (\node_modules\applicationinsights\out\AutoCollection\HttpRequestParser.js:217:26)\n' +
' at HttpRequestParser.getRequestTags (\node_modules\applicationinsights\out\AutoCollection\HttpRequestParser.js:118:110)\n' +
' at AutoCollectHttpRequests.endRequest (\node_modules\applicationinsights\out\AutoCollection\HttpRequests.js:232:55)\n' +
' at ServerResponse. (\node_modules\applicationinsights\out\AutoCollection\HttpRequests.js:192:41)\n' +
' at Object.onceWrapper (node:events:631:28)\n' +
' at ServerResponse.clsBind (\node_modules\cls-hooked\context.js:172:17)\n' +
' at ServerResponse.emit (node:events:529:35)\n' +
' at ServerResponse.emitted (\node_modules\emitter-listener\listener.js:134:21)\n' +
" at onFinish (node:_http_outgoing:1008:10)', message: 'URI malformed', name: 'URIError'"
]

Could you advise / provide some context as to why this might occur? the Module is being loaded relatively simply using the application insights connection string

const appInsights = require('applicationinsights')
appInsights
.setup()
appInsights.defaultClient.context.tags[appInsights.defaultClient.context.keys.cloudRole] = 'our-name'
appInsights.start()

I wouldn't be surprised if a malformed request had caused the error (most day to day requests are not causing the error), however I don't understand what the auth cookie aspect refers to.

Many thanks

@JacksonWeber JacksonWeber self-assigned this Dec 11, 2024
@JacksonWeber
Copy link
Contributor

JacksonWeber commented Dec 11, 2024

@DevRCRun We try to parse some values from cookies in the HttpRequestParser. This warning comes from a function concerned with parsing the ai_authUser from the request's cookies. We run decodeURI() on the cookie when trying to get this value. If that function throws an error we catch and log the warning you're seeing above. As the exception is handled and just a warning is logged, this shouldn't impact export of request telemetry.

What format is your authUser cookie in?

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

No branches or pull requests

2 participants