Skip to content

IgxDateFormatterPipe throws TypeError: Cannot read properties of undefined (reading 'length') when format is undefined after Angular 22.1 upgrade #17493

Description

@ivanvpetrov

Description

Summary

After upgrading to Angular 22.1, BaseFormatter.formatDate() throws a TypeError when the format argument is undefined (i.e. not provided by the caller). This is a regression caused by a new validation call (assertValidDateFormatLength) introduced in Angular 22.1's formatDate().

function assertValidDateFormatLength(format: string) {
  if (format.length > MAX_DATE_FORMAT_LENGTH) {  //.length throws an error
    throw new RuntimeError(
      RuntimeErrorCode.SUSPICIOUS_DATE_FORMAT,
      ngDevMode &&
        `Date format is too long. Exceeded maximum length of ${MAX_DATE_FORMAT_LENGTH} characters.`,
    );
  }
}

Angular Version

Broken in: 22.1.0
Works in: 22.0.x

Ignite UI for Angular Version

22.0

Steps to Reproduce

  1. Checkout branch ipetrov/ng-update-22.1.0 (Ipetrov/ng update 22.1.0 #17488 )
  2. Run tests. *(fit the tests below)
  3. Date/Time/DateTime: Use default locale format as inputFormat when editorOptions/pipeArgs formats are null/empty and Should not throw error when entities are empty and expressionTree is set. will throw TypeError: Cannot read properties of undefined (reading 'length')

Metadata

Metadata

Assignees

Labels

🐛 bugAny issue that describes a bug✅ status: resolvedApplies to issues that have pending PRs resolving them, or PRs that have already merged.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions