@serverless/sdk
Advanced tools
Comparing version 0.5.19 to 0.5.20
@@ -5,2 +5,9 @@ # Changelog | ||
### [0.5.20](https://github.com/serverless/console/compare/@serverless/sdk@0.5.19...@serverless/sdk@0.5.20) (2023-06-07) | ||
### Features | ||
- Enforce limits on tag values ([8985b99](https://github.com/serverless/console/commit/8985b99b3c56cf8de30a50b3c855301eef84c25c)) | ||
- Enforce max length on tag name ([38a771b](https://github.com/serverless/console/commit/38a771bb9d072f0c6d7c7bd1bf82870223a31317)) | ||
### [0.5.19](https://github.com/serverless/console/compare/@serverless/sdk@0.5.18...@serverless/sdk@0.5.19) (2023-05-18) | ||
@@ -7,0 +14,0 @@ |
@@ -9,2 +9,3 @@ 'use strict'; | ||
const resolveNonErrorName = require('./resolve-non-error-name'); | ||
const limitTagValue = require('./limit-tag-value'); | ||
@@ -33,8 +34,9 @@ const typeMap = new Map([ | ||
tags.name = error.name; | ||
tags.message = error.message; | ||
tags.message = limitTagValue(error.message); | ||
} else { | ||
tags.name = options._name || resolveNonErrorName(error); | ||
tags.message = typeof error === 'string' ? error : util.inspect(error); | ||
tags.message = limitTagValue(typeof error === 'string' ? error : util.inspect(error)); | ||
} | ||
tags.stacktrace = options._stack || resolveStackTraceString(error); | ||
tags.stacktrace = limitTagValue(options._stack || resolveStackTraceString(error)); | ||
capturedEvent.tags.setMany(tags, { prefix: 'error' }); | ||
@@ -41,0 +43,0 @@ |
@@ -12,4 +12,5 @@ 'use strict'; | ||
const reportError = require('./report-error'); | ||
const MAX_VALUE_LENGTH = require('./max-tag-value-length'); | ||
const isValidTagName = RegExp.prototype.test.bind(/^[a-zA-Z0-9_.-]+$/); | ||
const isValidTagName = RegExp.prototype.test.bind(/^[a-zA-Z0-9_.-]{1,256}$/); | ||
@@ -38,3 +39,12 @@ const ensureTagName = (() => { | ||
return (inputValue, tagName) => { | ||
if (typeof inputValue === 'string') return inputValue; | ||
if (typeof inputValue === 'string') { | ||
if (Buffer.from(inputValue).length > MAX_VALUE_LENGTH) { | ||
return resolveException(inputValue, null, { | ||
errorCode, | ||
errorMessage: `Invalid trace span tag value for "${tagName}": Too large string:"%v"`, | ||
Error: ServerlessSdkError, | ||
}); | ||
} | ||
return inputValue; | ||
} | ||
if (typeof inputValue === 'number') { | ||
@@ -53,3 +63,3 @@ return ensureFinite(inputValue, { | ||
let type = null; | ||
return inputValue.map((item) => { | ||
const normalizedValue = inputValue.map((item) => { | ||
if (typeof item === 'string') { | ||
@@ -89,2 +99,10 @@ if (type == null) type = 'string'; | ||
}); | ||
if (Buffer.from(JSON.stringify(normalizedValue)).length > MAX_VALUE_LENGTH) { | ||
return resolveException(inputValue, null, { | ||
errorCode, | ||
errorMessage: `Invalid trace span tag value for "${tagName}": Too large value:"%v"`, | ||
Error: ServerlessSdkError, | ||
}); | ||
} | ||
return normalizedValue; | ||
} | ||
@@ -91,0 +109,0 @@ return resolveException(inputValue, null, { |
{ | ||
"name": "@serverless/sdk", | ||
"repository": "serverless/console", | ||
"version": "0.5.19", | ||
"version": "0.5.20", | ||
"author": "Serverless, Inc.", | ||
@@ -6,0 +6,0 @@ "dependencies": { |
88803
42
1690