Skip to content

Commit aef13c0

Browse files
authored
fix: don't quote CloudWatch filter pattern (#702)
fix: don't quote CloudWatch filter pattern (#702) BREAKING CHANGE: The filter pattern to match CloudWatch Logs is now passed without modifications to the AWS API. If you're using the Jest `toHaveLog` or Chai `to.have.log` matchers you might need to quote your pattern, e.g. `toHaveLog(pattern) -> toHaveLog("${pattern}")` or `to.have.log(pattern) -> to.have.log("${pattern}")` to support special characters
1 parent ba36f4b commit aef13c0

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/utils/cloudwatch.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describe('cloudwatch utils', () => {
9292
expect(cloudWatchLogs).toHaveBeenCalledWith({ region });
9393
expect(filterLogEvents).toHaveBeenCalledTimes(1);
9494
expect(filterLogEvents).toHaveBeenCalledWith({
95-
filterPattern: `"${filterPattern}"`,
95+
filterPattern,
9696
interleaved: true,
9797
limit: 1,
9898
logGroupName,

src/utils/cloudwatch.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ export const filterLogEvents = async (
77
region: string,
88
logGroupName: string,
99
startTime: number,
10-
pattern: string,
10+
filterPattern: string,
1111
) => {
1212
const cloudWatchLogs = new AWS.CloudWatchLogs({ region });
13-
const filterPattern = `"${pattern}"`; // enclose with "" to support special characters
1413

1514
const { events = [] } = await cloudWatchLogs
1615
.filterLogEvents({

0 commit comments

Comments
 (0)