Skip to content

fix: createActions should not garble baseclass metadata #1127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 27, 2023

Conversation

wamasimba
Copy link
Contributor

Description

A more concise re-implementation of the createActions() method. Essence of this is that the target property of the metadata is not changed in-place, which hindered using a base class multiple times.

Checklist

  • the pull request title describes what this PR does (not a vague title like Update index.md)
  • the pull request targets the default branch of the repository (develop)
  • the code follows the established code style of the repository
    • npm run prettier:check passes
    • npm run lint:check passes
  • tests are added for the changes I made (if any source code was modified)
  • documentation added or updated
  • I have run the project locally and verified that there are no errors

Fixes

fixes #1124

Essence of this is that the target property of the metadata is not changed in-place.
@@ -125,7 +131,7 @@ describe('controller inheritance', () => {
expect(storage.controllers[0].route).to.be.eq('/derivative');
expect(storage.controllers[1].target).to.be.eq(AutonomousController);
expect(storage.controllers[1].route).to.be.eq('/autonomous');
expect(storage.actions[0].target).to.be.eq(DerivativeController);
expect(storage.actions[0].target).to.be.eq(AbstractControllerTemplate);
Copy link
Member

Choose a reason for hiding this comment

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

Is it intentional that the abstract controller is registered too? Seems like it wasn't the case before

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed it is; the actions in the storage are actually the base data (ActionMetadataArgs) and are shared amongst all deriving classes. If it were altered (as a previous change introduced), only the first derived class 'gets' the actions; the action from the storage is used to create the ActualMetadata in createActions(), and only at that place, the controller.target is filled in as target for the action (which is not the action metadata that is subject of this unit test).

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, you are right. Seems like we had an incorrect reference mutation, the fix was just obscured a bit by the structure change :).

Thanks for the contribution!

@attilaorosz attilaorosz merged commit 126719a into typestack:develop Apr 27, 2023
spicemc added a commit to spicemc/rce that referenced this pull request May 23, 2023
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

use base class and inheriting twice is broken
2 participants