Skip to content

Commit 52242bb

Browse files
committed
Fixed a bug/typo in the subject field validation
1 parent d01532b commit 52242bb

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/eventarc/eventarc-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export function toCloudEventProtoFormat(ce: CloudEvent): any {
8080
});
8181
}
8282
if (ce.subject) {
83-
if (!validator.isNonEmptyString(ce.datacontenttype)) {
83+
if (!validator.isNonEmptyString(ce.subject)) {
8484
throw new FirebaseEventarcError(
8585
'invalid-argument',
8686
"CloudEvent 'subject' if specified must be non-empty string.");

test/unit/eventarc/eventarc-utils.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ describe('eventarc-utils', () => {
4545
expect(utils.toCloudEventProtoFormat({
4646
type: 'some.custom.event',
4747
specversion: '1.0',
48+
subject: 'context',
4849
datacontenttype: 'application/json',
4950
id: 'user-provided-id',
5051
data: {
@@ -64,6 +65,9 @@ describe('eventarc-utils', () => {
6465
},
6566
'time': {
6667
'ceTimestamp': '2022-03-16T20:20:42.212Z'
68+
},
69+
'subject': {
70+
'ceString': 'context'
6771
}
6872
},
6973
'id': 'user-provided-id',

0 commit comments

Comments
 (0)