@@ -256,20 +256,41 @@ function hasRuntimeReference(value: string): boolean {
256256}
257257
258258/**
259- * Outside Function code a reference resolves to JSON text (objects, numbers, booleans), so
259+ * Outside Function code a reference resolves to JSON text (objects, arrays, numbers, booleans), so
260260 * `{"name": <start.name>}` or a whole-field `<start.row>` is valid JSON at runtime but not before.
261- * Quoting each reference written outside a JSON string lets the Table block's own parser read the
262- * literal parts, and the quoted references then reach the existing runtime-resolution notes.
263- * Only this lint-local copy is rewritten; references to string outputs left unquoted are reported
264- * separately by `collectUnquotedJsonStringReferences`.
261+ * Quoting each reference written outside a JSON string lets the Table block's own transform read
262+ * the literal parts, and the quoted references then reach the existing runtime-resolution notes.
263+ * When the transform's shape validation rejects a quoted reference (a filter `in` list, a
264+ * whole-field filter), the fields that only parse once quoted are left out and returned as
265+ * `runtimeFields`; malformed literal JSON still throws. Only this lint-local copy is rewritten;
266+ * references to string outputs left unquoted are reported by `collectUnquotedJsonStringReferences`.
265267 */
266- function quoteBareReferenceParams ( params : Record < string , unknown > ) : Record < string , unknown > {
267- return Object . fromEntries (
268- Object . entries ( params ) . map ( ( [ key , value ] ) => [
269- key ,
270- typeof value === 'string' ? quoteBareReferences ( value ) : value ,
271- ] )
272- )
268+ function normalizeTableInputs (
269+ transform : ( params : Record < string , unknown > ) => Record < string , unknown > ,
270+ params : Record < string , unknown >
271+ ) : { normalized : Record < string , unknown > ; runtimeFields : string [ ] } {
272+ const quoted : Record < string , unknown > = { }
273+ const runtimeFields : string [ ] = [ ]
274+ for ( const [ key , value ] of Object . entries ( params ) ) {
275+ quoted [ key ] = typeof value === 'string' ? quoteBareReferences ( value ) : value
276+ if ( quoted [ key ] !== value && parsesAsJson ( quoted [ key ] ) ) runtimeFields . push ( key )
277+ }
278+ try {
279+ return { normalized : transform ( quoted ) , runtimeFields : [ ] }
280+ } catch ( error ) {
281+ if ( runtimeFields . length === 0 ) throw error
282+ for ( const key of runtimeFields ) delete quoted [ key ]
283+ return { normalized : transform ( quoted ) , runtimeFields }
284+ }
285+ }
286+
287+ function parsesAsJson ( value : unknown ) : boolean {
288+ try {
289+ JSON . parse ( String ( value ) )
290+ return true
291+ } catch {
292+ return false
293+ }
273294}
274295
275296function quoteBareReferences ( json : string ) : string {
@@ -357,7 +378,13 @@ async function readTableDiagnostics(
357378 if ( ! transform ) throw new Error ( 'Table input normalization is unavailable' )
358379 let normalized : Record < string , unknown >
359380 try {
360- normalized = transform ( quoteBareReferenceParams ( params ) )
381+ const inputs = normalizeTableInputs ( transform , params )
382+ normalized = inputs . normalized
383+ if ( inputs . runtimeFields . length > 0 ) {
384+ result . notes . push (
385+ `Table inputs in block "${ block . name || blockId } " depend on references resolved at runtime and were not checked: ${ inputs . runtimeFields . join ( ', ' ) } .`
386+ )
387+ }
361388 } catch ( error ) {
362389 result . notes . push (
363390 `Table input checks in block "${ block . name || blockId } " could not complete before runtime: ${ getErrorMessage ( error ) } `
0 commit comments