Skip to content

[SEMVER-MAJOR] throw error for undefined mixin#944

Merged
alexpit merged 1 commit into
masterfrom
fix-mixin-err-handler
May 31, 2016
Merged

[SEMVER-MAJOR] throw error for undefined mixin#944
alexpit merged 1 commit into
masterfrom
fix-mixin-err-handler

Conversation

@alexpit
Copy link
Copy Markdown

@alexpit alexpit commented May 24, 2016

connect to #566

@alexpit alexpit force-pushed the fix-mixin-err-handler branch from c8f4246 to b1285ce Compare May 24, 2016 20:24
@alexpit
Copy link
Copy Markdown
Author

alexpit commented May 24, 2016

@bajtos, please review. thanks

@alexpit alexpit assigned alexpit and bajtos and unassigned alexpit May 24, 2016
@richardpringle
Copy link
Copy Markdown

@alexpit, don't forget to update the release notes!

Comment thread lib/mixins.js Outdated
modelClass.mixin(model, options);
} else {
debug('Invalid mixin: %s', name);
throw new Error('Invalid mixin: ' + name);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please include the model name in the error message, otherwise it's impossible to find the model which is referencing this missing mixing.

I would also reword the message a bit, e.g.

'Model ' + modelClass.modelName + ' uses unknown mixin ' + name

@bajtos bajtos assigned alexpit and unassigned bajtos May 25, 2016
@bajtos
Copy link
Copy Markdown
Member

bajtos commented May 25, 2016

@alexpit thank you for the pull request, you are headed in the right direction! I left few comments to address, see above.

@alexpit
Copy link
Copy Markdown
Author

alexpit commented May 25, 2016

@richardpringle, please review. thx

@alexpit
Copy link
Copy Markdown
Author

alexpit commented May 25, 2016

@bajtos, please review addressed comments. thx

Comment thread 3.0-RELEASE-NOTES.md Outdated
silently ignored. This has been fixed in 3.0, therefore an undefined mixin
applied to a LoopBack model will throw an error that needs to be handled.

Please see [related code change](https://github.com/strongloop/loopback-datasource-juggler/pull/944) No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit pick:

Please see [related code change]() for details.

@richardpringle richardpringle assigned bajtos and unassigned alexpit May 25, 2016
Comment thread lib/mixins.js Outdated
var model = this.modelBuilder.getModel(name);
if (model) {
debug('Mixin is resolved to a model: %s', name);
debug('Mixin "' + name + '" resolves to model: %s', modelClass.modelName);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not correct. Mixin "name" is resolved to a model called "name" in this branch, and then it is applied to another model called "modelClass.modelName".

It's better to avoid making unrelated code changes, as it makes code archaeology more difficult.

Please revert this line.

@bajtos bajtos assigned alexpit and unassigned bajtos May 26, 2016
@alexpit
Copy link
Copy Markdown
Author

alexpit commented May 26, 2016

@bajtos, please review addressed comments. thx

@bajtos bajtos changed the title fix error handling when applying undefined mixins [SEMVER-MAJOR] fix error handling when applying undefined mixins May 27, 2016
@bajtos bajtos changed the title [SEMVER-MAJOR] fix error handling when applying undefined mixins [SEMVER-MAJOR] throw an error when applying undefined mixin May 27, 2016
@bajtos
Copy link
Copy Markdown
Member

bajtos commented May 27, 2016

LGTM 👏

Please squash the commits before landing, the commands are git rebase -i master and git push -f.

@Amir-61
Copy link
Copy Markdown
Contributor

Amir-61 commented May 29, 2016

Hey @bajtos and @alexpit,

@bajtos Does Alex need to backprot this change?

@alexpit For loopback-datasource-juggler, we may need to backport the changes to 2.x branch as well; please see our team documentation. If @bajtos confirmed that you need to backport the changes, please let me know if you need any help for backproting and I can walk you through the steps.

Thanks :-)

@richardpringle
Copy link
Copy Markdown

richardpringle commented May 29, 2016

Woah, dependent loopback failed, that can't be good. Also, @alexpit, i'll help you with squashing.

@bajtos, git push -f? That will force push master. Should be git push origin +branch_name no?

@Amir-61
Copy link
Copy Markdown
Contributor

Amir-61 commented May 29, 2016

@bajtos, git push -f? That will force push master. Should be git push origin +branch_name no?

I believe Miroslav meant run git push -f when you are in your feature branch and after rebasing and squashing the commits in feature branch.

@richardpringle
Copy link
Copy Markdown

I believe that depends on your push policy configuration. It's safer to explicitly push a certain branch with '+' causing the force push.

@bajtos
Copy link
Copy Markdown
Member

bajtos commented May 30, 2016

Does Alex need to backprot this change?

No, we cannot back-port breaking changes.

git push -f? That will force push master. Should be git push origin +branch_name no?

I believe Miroslav meant run git push -f when you are in your feature branch and after rebasing and squashing the commits in feature branch.

I believe that depends on your push policy configuration. It's safer to explicitly push a certain branch with '+' causing the force push.

Interesting. I think it's rather unlikely that one would one end up with a feature branch configured to be pushed to a long-lived remote branch like master, but then there is no harm in being cautious.

BTW in some repositories, we have locked long-lived branches like master and 2.x to reject force-pushes. If you find a repository that does not have master locked, then feel free to make the change yourself.

@bajtos
Copy link
Copy Markdown
Member

bajtos commented May 30, 2016

@slnode test please

@alexpit alexpit changed the title [SEMVER-MAJOR] throw an error when applying undefined mixin [SEMVER-MAJOR] throw error for undefined mixin May 30, 2016
@alexpit alexpit force-pushed the fix-mixin-err-handler branch from 3547299 to e0e31ca Compare May 30, 2016 18:52
@alexpit
Copy link
Copy Markdown
Author

alexpit commented May 31, 2016

@bajtos please review

@bajtos
Copy link
Copy Markdown
Member

bajtos commented May 31, 2016

PR Linter — PR out of date, needs to be rebased

@alexpit could you please rebase on top of the current master?

@alexpit
Copy link
Copy Markdown
Author

alexpit commented May 31, 2016

@slnode test please

@alexpit alexpit force-pushed the fix-mixin-err-handler branch from e0e31ca to 423db34 Compare May 31, 2016 16:26
@alexpit alexpit merged commit 5b02507 into master May 31, 2016
@alexpit alexpit deleted the fix-mixin-err-handler branch May 31, 2016 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants