@@ -3442,9 +3442,9 @@ describe("normalizeAndValidateConfig()", () => {
34423442 ` ) ;
34433443 } ) ;
34443444
3445- it ( "should error if unsafe.bindings, unsafe.metadata and unsafe.capnp are undefined " , ( ) => {
3445+ it ( "should not error if unsafe is an empty object " , ( ) => {
34463446 const { diagnostics } = normalizeAndValidateConfig (
3447- { unsafe : { } } as unknown as RawConfig ,
3447+ { unsafe : { } } satisfies RawConfig ,
34483448 undefined ,
34493449 { env : undefined }
34503450 ) ;
@@ -3454,42 +3454,36 @@ describe("normalizeAndValidateConfig()", () => {
34543454 - \\"unsafe\\" fields are experimental and may change or break at any time."
34553455 ` ) ;
34563456 expect ( diagnostics . renderErrors ( ) ) . toMatchInlineSnapshot ( `
3457- "Processing wrangler configuration:
3458- - The field \\"unsafe\\" should contain at least one of \\"bindings\\", \\"metadata\\" or \\"capnp\\" properties but got {}."
3459- ` ) ;
3460- } ) ;
3461-
3462- it ( "should not error if at least unsafe.bindings is defined" , ( ) => {
3463- const { diagnostics } = normalizeAndValidateConfig (
3464- { unsafe : { bindings : [ ] } } as unknown as RawConfig ,
3465- undefined ,
3466- { env : undefined }
3467- ) ;
3468-
3469- expect ( diagnostics . renderWarnings ( ) ) . toMatchInlineSnapshot ( `
3470- "Processing wrangler configuration:
3471- - \\"unsafe\\" fields are experimental and may change or break at any time."
3472- ` ) ;
3473- expect ( diagnostics . hasErrors ( ) ) . toBe ( false ) ;
3457+ "Processing wrangler configuration:
3458+ "
3459+ ` ) ;
34743460 } ) ;
34753461
3476- it ( "should not error if at least unsafe.metadata is defined " , ( ) => {
3462+ it ( "should error if unsafe contains unexpected properties " , ( ) => {
34773463 const { diagnostics } = normalizeAndValidateConfig (
3478- { unsafe : { metadata : { } } } as unknown as RawConfig ,
3464+ {
3465+ unsafe : {
3466+ invalid : true ,
3467+ } ,
3468+ } as RawConfig ,
34793469 undefined ,
34803470 { env : undefined }
34813471 ) ;
34823472
34833473 expect ( diagnostics . renderWarnings ( ) ) . toMatchInlineSnapshot ( `
3484- "Processing wrangler configuration:
3485- - \\"unsafe\\" fields are experimental and may change or break at any time."
3486- ` ) ;
3487- expect ( diagnostics . hasErrors ( ) ) . toBe ( false ) ;
3474+ "Processing wrangler configuration:
3475+ - \\"unsafe\\" fields are experimental and may change or break at any time.
3476+ - Unexpected fields found in unsafe field: \\"invalid\\""
3477+ ` ) ;
3478+ expect ( diagnostics . renderErrors ( ) ) . toMatchInlineSnapshot ( `
3479+ "Processing wrangler configuration:
3480+ "
3481+ ` ) ;
34883482 } ) ;
34893483
34903484 it ( "should error if unsafe.bindings is an object" , ( ) => {
34913485 const { diagnostics } = normalizeAndValidateConfig (
3492- { unsafe : { bindings : { } } } as unknown as RawConfig ,
3486+ { unsafe : { bindings : { } } } as RawConfig ,
34933487 undefined ,
34943488 { env : undefined }
34953489 ) ;
@@ -5164,32 +5158,30 @@ describe("normalizeAndValidateConfig()", () => {
51645158 ` ) ;
51655159 } ) ;
51665160
5167- it ( "should error if unsafe.bindings, unsafe.metadata and unsafe.capnp are undefined " , ( ) => {
5161+ it ( "should not error if unsafe is an empty object " , ( ) => {
51685162 const { diagnostics } = normalizeAndValidateConfig (
5169- { env : { ENV1 : { unsafe : { } } } } as unknown as RawConfig ,
5163+ { env : { ENV1 : { unsafe : { } } } } as RawConfig ,
51705164 undefined ,
51715165 { env : "ENV1" }
51725166 ) ;
51735167
51745168 expect ( diagnostics . renderWarnings ( ) ) . toMatchInlineSnapshot ( `
5175- "Processing wrangler configuration:
5169+ "Processing wrangler configuration:
51765170
5177- - \\"env.ENV1\\" environment configuration
5178- - \\"unsafe\\" fields are experimental and may change or break at any time."
5179- ` ) ;
5171+ - \\"env.ENV1\\" environment configuration
5172+ - \\"unsafe\\" fields are experimental and may change or break at any time."
5173+ ` ) ;
51805174 expect ( diagnostics . renderErrors ( ) ) . toMatchInlineSnapshot ( `
5181- "Processing wrangler configuration:
5182-
5183- - \\"env.ENV1\\" environment configuration
5184- - The field \\"env.ENV1.unsafe\\" should contain at least one of \\"bindings\\", \\"metadata\\" or \\"capnp\\" properties but got {}."
5185- ` ) ;
5175+ "Processing wrangler configuration:
5176+ "
5177+ ` ) ;
51865178 } ) ;
51875179
51885180 it ( "should not error if at least unsafe.bindings is undefined" , ( ) => {
51895181 const { diagnostics } = normalizeAndValidateConfig (
51905182 {
51915183 env : { ENV1 : { unsafe : { bindings : [ ] } } } ,
5192- } as unknown as RawConfig ,
5184+ } as RawConfig ,
51935185 undefined ,
51945186 { env : "ENV1" }
51955187 ) ;
@@ -5203,22 +5195,26 @@ describe("normalizeAndValidateConfig()", () => {
52035195 expect ( diagnostics . hasErrors ( ) ) . toBe ( false ) ;
52045196 } ) ;
52055197
5206- it ( "should not error if at least unsafe.metadata is undefined " , ( ) => {
5198+ it ( "should error if unsafe contains unexpected properties " , ( ) => {
52075199 const { diagnostics } = normalizeAndValidateConfig (
52085200 {
5209- env : { ENV1 : { unsafe : { metadata : { } } } } ,
5210- } as unknown as RawConfig ,
5201+ env : { ENV1 : { unsafe : { invalid : true } } } ,
5202+ } as RawConfig ,
52115203 undefined ,
52125204 { env : "ENV1" }
52135205 ) ;
52145206
52155207 expect ( diagnostics . renderWarnings ( ) ) . toMatchInlineSnapshot ( `
5216- "Processing wrangler configuration:
5208+ "Processing wrangler configuration:
52175209
5218- - \\"env.ENV1\\" environment configuration
5219- - \\"unsafe\\" fields are experimental and may change or break at any time."
5220- ` ) ;
5221- expect ( diagnostics . hasErrors ( ) ) . toBe ( false ) ;
5210+ - \\"env.ENV1\\" environment configuration
5211+ - \\"unsafe\\" fields are experimental and may change or break at any time.
5212+ - Unexpected fields found in unsafe field: \\"invalid\\""
5213+ ` ) ;
5214+ expect ( diagnostics . renderErrors ( ) ) . toMatchInlineSnapshot ( `
5215+ "Processing wrangler configuration:
5216+ "
5217+ ` ) ;
52225218 } ) ;
52235219
52245220 it ( "should error if unsafe.bindings is an object" , ( ) => {
0 commit comments