Skip to content

Conversation

@matmen
Copy link
Member

@matmen matmen commented Jun 1, 2025

When a macro is removed from the config, it isn't deleted from the stored config in the database. This can lead to an undefined property access while looking up the stored macro data:

image

@matmen matmen added this to the 1.34.3 milestone Jun 1, 2025
@matmen matmen requested a review from pedrolamas June 1, 2025 13:24
@matmen matmen added the GH - Bug Something isn't working label Jun 1, 2025
Copy link
Member

@pedrolamas pedrolamas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @matmen, I haven't been able to reproduce this, but codewise I see no problem with this change!

Oddly, I can't even find any macro2.name on the code...

From what I can see, we have macro settings in the store that have no name, is that it?

That should not be the case, but this will fix the issue, no question about it!

@pedrolamas
Copy link
Member

We do have similar code on the macro/mutations.ts, I do wonder if the same change should be done there?

@matmen
Copy link
Member Author

matmen commented Jun 1, 2025

Oddly, I can't even find any macro2.name on the code...

yep, me neither, i think that's just what the compilation changes it to tho. If i jump to the source code from the dev tools it marks that line, and I've tested the fix to be working ;)

From what I can see, we have macro settings in the store that have no name, is that it?

yep, i guess it's not being populated if it's not in the config. Alternatively we could just remove it from the saved macros, but that would delete all the saved settings if a user just decides to comment out the macro from the config for testing

We do have similar code on the macro/mutations.ts, I do wonder if the same change should be done there?

I don't think so - the code in there never runs because macros that aren't in the config can't be mutated either (they don't show up in the UI)

@pedrolamas
Copy link
Member

The thing is that the stored settings are populated from whatever is currently on the existing macros... So I don't get how one could go without a name!

I get that this fixes the problem, I just don't see how deleting/commenting out a macro would cause this as we already have the macro setting stored - we just won't use it as he macro is gone now!

@matmen
Copy link
Member Author

matmen commented Jun 1, 2025

... as we already have the macro setting stored - we just won't use it as he macro is gone now!

well, that's the thing, we do use the stored macro settings as we iterate over each one in state.stored.find() ;)

I can take a look at what's actually stored in my moonraker db tomorrow - perhaps the stored data was corrupted somehow and is just missing the name attribute. Either way, I think it wouldn't hurt to merge this if it's ok with you, just in case someone else runs into the same issue

@pedrolamas
Copy link
Member

Agreed, merge away, I see no problem with this change!

@matmen matmen merged commit d2335a9 into fluidd-core:develop Jun 2, 2025
4 checks passed
@matmen matmen deleted the fix/deleted-macros-store branch June 2, 2025 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GH - Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants