Skip to content

Enhancement: DynamicTable.validateRows() should warn about or strip unknown fields not in schema #11

@wagnert

Description

@wagnert

Enhancement Request

DynamicTable.validateRows() currently only validates fields that ARE defined in the schema. Fields in the row object that are NOT in the schema are silently passed through to the AppSheet API.

Current Behavior

// DynamicTable.validateRows() (simplified, lines 62-81)
for (const field of schemaFields) {
  validateFieldType(row[field.name], field.type);
}
// ← Fields in row that are NOT in schema are IGNORED
// ← They pass through 1:1 to the AppSheet API

When a consumer accidentally adds a field that doesn't exist in the AppSheet table (e.g. id, or a renamed field like type instead of types), validateRows() does not catch it. The invalid field is sent to the API, which rejects with:

"Failed to get rows due to: 'id' is not a valid table column name.."

Expected Behavior

As a defense-in-depth measure, DynamicTable should detect fields in the row object that are not defined in the table schema. Options (configurable):

  1. Warn — Log a warning for unknown fields (non-breaking)
  2. Strip — Remove unknown fields before sending to API (safe default)
  3. Strict mode — Throw an error for unknown fields (opt-in)

Suggested API

// Option A: Configuration on DynamicTable
const table = schemaManager.table<Solution>('default', 'solution', email, {
  unknownFields: 'strip' // 'warn' | 'strip' | 'error' | 'ignore' (default)
});

// Option B: Global SchemaManager configuration
const schemaManager = new SchemaManager(factory, schema, {
  unknownFieldPolicy: 'warn'
});

Use Cases This Would Catch

  1. Stale field names after rename — e.g. type instead of types after schema migration
  2. Mock workaround fields — e.g. adding id field for MockAppSheetClient compatibility
  3. Typos in field names — e.g. desciption instead of description

Impact

  • Low risk enhancement — current behavior (ignore) remains the default
  • Would have prevented BUG-ASUP-001 and BUG-ASUP-002 in service_portfolio_mcp
  • The schema already contains all field definitions — the information is available

Environment

  • @techdivision/appsheet v3.1.0
  • Discovered in: service_portfolio_mcp project

Related

  • Downstream bugs prevented: BUG-ASUP-001 (stale field names), BUG-ASUP-002 (extra id field)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions