components
components copied to clipboard
bug(schematics): migration schmatics report error without much useful information
Is this a regression?
- [ ] Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
Cannot read properties of undefined (reading 'sourceSpan')
Reproduction
N/A
Expected Behavior
Report file, relevant module and other useful information.
Actual Behavior
Cannot read properties of undefined (reading 'sourceSpan')
and nothing else.
Environment
- Angular: 15.0.0
- CDK/Material: 15.0.0
@princemaple Does the error point to a file & line number, or is this the full error message? Also, do you have an idea of which file triggered this error? If so, would you mind sharing it's contents so we can see where the parsing failed?
@princemaple Does the error point to a file & line number, or is this the full error message? Also, do you have an idea of which file triggered this error? If so, would you mind sharing it's contents so we can see where the parsing failed?
That's all I got. I know which project, that's all. I don't know which file, which module. And no line number was reported. Unless there is a verbose mode that I haven't tried, I think that's all I got.
I have a repo that has several projects in it. I think only one of them is having this issue but don't know which file. I've been migrating the other projects one by one, by limiting the migration path to projects/X.
FYI it's not ng update. Ng update worked fine. It's the separate migration schematic.
Hmm, I have a few guesses on what the root cause could be, but without good error logs I'll have to settle for improving the logging as an intermediary step. I'll try and land something before this Wednesday so it's included in the next patch release 👍🏽
Thanks a lot 😊 I'll report back when there are more error messages shown.
I'm seeing the same error.
I've narrowed it down to the card component by just selecting and deselecting the options in the CLI, but I cannot find the exact source file it has problems with because it seems to apply all the migrations just fine even if I do not select "card" to be migrated. I am definitely using cards in my project though.
Looking at git, the only thing it adds is some comments in style files where I override some styles and renames mat-chip-list
to mat-chip-grid
and mat-chip
to mat-chip-row
.
Same for me. If I select all the components except card, then the migration will be successful. If I select card, then it gives the mysterious red message Cannot read properties of undefined (reading 'sourceSpan')
Did 15.0.1 not come out last week?
Hello @wagnermaciel , I'm reporting back about the mdc migration.
Your undefined
fix made it possible for the migration script to finish. I noticed this weird thing after migration:
Looks like multi line mat-card tag gave the migration script a hard time, and the previous error? Not sure if it's the real cause. Anyway, I'm very glad that I can finish this migration by just adding a space.
I'm quite surprised that this is the only place where I have a mat-card that spanned multiple lines. I'd think there were more, given how often I use mat-card :)
Hey, that's sorta good news I guess 😅 Yeah, I think we missed a release bc of the short Thanksgiving week
I don't think multi-line mat-cards are what is causing the error, though, since we have a test for that: https://github.com/angular/components/blob/main/src/material/schematics/ng-generate/mdc-migration/rules/components/card/card-template.spec.ts#L99
Could you post the full <mat-card ...
snippet? I can't reproduce the new issue in our tests
This is what the file looked like prior to the migration.
<ng-container cdkDropListGroup>
<mat-card
*ngFor="let uc of userClients | async"
[class.inactive]="!uc.user.active"
[style.display]="!uc.user.active && !uc.clients?.length ? 'none' : 'block'"
>
<mat-card-title>
{{ uc.user.name }}
</mat-card-title>
<mat-card-subtitle>
{{ uc.user.sid }}
</mat-card-subtitle>
<mat-card-content>
<mat-list cdkDropList (cdkDropListDropped)="assignTo(uc.user, $event)">
<mat-list-item *ngFor="let client of uc.clients" cdkDrag [cdkDragData]="client">
<p mat-line [title]="client.name">{{ countries[client.country].cn }} {{ client.name }}</p>
</mat-list-item>
</mat-list>
</mat-card-content>
</mat-card>
</ng-container>
Mine.
<mat-card
[style.width]="na === 1 ? '90%' : '18rem'"
>
becomes
<mat-cardappearance="outlined"
[style.width]="na === 1 ? '90%' : '18rem'"
>
Latching onto this issue because it looks essentially the same.
Two differences though.
The error is Cannot read properties of undefined (reading 'length')
and limiting to certain components doesn't change anything.
Would love some sort of verbose option to post something more meaningful.
I got the message "Cannot read properties of undefined (reading 'text')"
I got same message as @ThRintelen . I also have "Cannot read properties of undefined (reading 'length')"
@wagnermaciel For more info, the error is happening in this line because node
is undefined
:
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.