@@ -260,31 +260,33 @@ function hasRuntimeReference(value: string): boolean {
260260 * `{"name": <start.name>}` or a whole-field `<start.row>` is valid JSON at runtime but not before.
261261 * Each reference written outside a JSON string is replaced by a placeholder so the Table block's
262262 * own transform reads the literal parts: a quoted string, or a one-item list for slots such as a
263- * filter `in`. Every combination is tried while there are few references (otherwise all-string
264- * and all-list). A field that is a single whole reference has no literal part, so if no
265- * combination fits it is left out and returned in `runtimeFields`. Any other failure, such as
266- * malformed JSON or an invalid literal condition, is rethrown. Only this lint-local copy is
267- * rewritten; references to string outputs left unquoted are reported by
263+ * filter `in`, trying every combination. A field that is a single whole reference has no literal
264+ * part, so if no combination fits it is left out and returned in `runtimeFields`. When the search
265+ * is exhaustive and still fails, the error comes from the literal parts (malformed JSON, an
266+ * invalid literal condition) and is rethrown. Past the search bound that cannot be told apart, so
267+ * every reference-bearing field is left out instead and the other inputs are still checked. Only
268+ * this lint-local copy is rewritten; references to string outputs left unquoted are reported by
268269 * `collectUnquotedJsonStringReferences`.
269270 */
270271function normalizeTableInputs (
271272 transform : ( params : Record < string , unknown > ) => Record < string , unknown > ,
272273 params : Record < string , unknown >
273274) : { normalized : Record < string , unknown > ; runtimeFields : string [ ] } {
274- let hasReference = false
275+ const referenceFields : string [ ] = [ ]
275276 const wholeReferenceFields : string [ ] = [ ]
276277 for ( const [ key , value ] of Object . entries ( params ) ) {
277278 if ( typeof value !== 'string' ) continue
278279 const trimmed = value . trim ( )
279280 const tokens = findWorkflowReferenceTokens ( trimmed )
280281 if ( tokens . length === 0 ) continue
281- hasReference = true
282+ referenceFields . push ( key )
282283 if ( tokens . length === 1 && tokens [ 0 ] . start === 0 && tokens [ 0 ] . end === trimmed . length ) {
283284 wholeReferenceFields . push ( key )
284285 }
285286 }
286- if ( ! hasReference ) return { normalized : transform ( params ) , runtimeFields : [ ] }
287+ if ( referenceFields . length === 0 ) return { normalized : transform ( params ) , runtimeFields : [ ] }
287288 const tiers = wholeReferenceFields . length > 0 ? [ [ ] , wholeReferenceFields ] : [ [ ] ]
289+ let searchBounded = false
288290 let firstError : unknown
289291 for ( const runtimeFields of tiers ) {
290292 const withPlaceholders = ( asList : ( ordinal : number ) => boolean ) => {
@@ -302,22 +304,24 @@ function normalizeTableInputs(
302304 return { candidate, count : ordinal }
303305 }
304306 const { count } = withPlaceholders ( ( ) => false )
305- const assignments : Array < ( ordinal : number ) => boolean > =
306- count <= MAX_PLACEHOLDER_SEARCH_REFERENCES
307- ? Array . from (
308- { length : 2 ** count } ,
309- ( _ , mask ) => ( ordinal ) => ( ( mask >> ordinal ) & 1 ) === 1
310- )
311- : [ ( ) => false , ( ) => true ]
312- for ( const asList of assignments ) {
307+ if ( count > MAX_PLACEHOLDER_SEARCH_REFERENCES ) {
308+ searchBounded = true
309+ continue
310+ }
311+ for ( let mask = 0 ; mask < 2 ** count ; mask ++ ) {
313312 try {
314- return { normalized : transform ( withPlaceholders ( asList ) . candidate ) , runtimeFields }
313+ const { candidate } = withPlaceholders ( ( ordinal ) => ( ( mask >> ordinal ) & 1 ) === 1 )
314+ return { normalized : transform ( candidate ) , runtimeFields }
315315 } catch ( error ) {
316316 firstError ??= error
317317 }
318318 }
319319 }
320- throw firstError
320+ if ( ! searchBounded ) throw firstError
321+ const literal = Object . fromEntries (
322+ Object . entries ( params ) . filter ( ( [ key ] ) => ! referenceFields . includes ( key ) )
323+ )
324+ return { normalized : transform ( literal ) , runtimeFields : referenceFields }
321325}
322326
323327/** Bounds the placeholder search to 2^6 pure transform calls per Table block. */
0 commit comments