Skip to content
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

Bugfix/error annotate #1008

Merged
merged 4 commits into from
Oct 18, 2016
Merged

Conversation

LudwikJaniuk
Copy link
Contributor

Fixes #1005 (and I guess #1006 ?)

Added option for the color coding in `error.annotate`. Hope I did it
right.
This fixes the `error.annotate` footnote number bug. It was a simple
brainfart, the author was probably thinking he needed to invert the
index when that was not actually needed.
@Marsup
Copy link
Collaborator

Marsup commented Oct 14, 2016

The tests fail because default arguments are not supported in node 4 and there's also a typo in your code. Also you'll be lacking some additional tests to validate your change, this should go inside this block (https://github.com/hapijs/joi/blob/master/test/errors.js#L366), you can find inspiration from other tests to do your owns. Let me know if you need more help.

@LudwikJaniuk
Copy link
Contributor Author

Alright, will try to fix these problems. I assume that since I can't use default arguments, that I should use null-checking?

Also, a question: I noticed that while this makes the references correct, their order still does not feel quite natural. I'd like to also change it so that they come in the natural order from top to bottom. However, this does not seem that easy. What can I assume about the order of Error.details? And I see you're doing some specific stuff with the order (a comment talks about taking the innermost children first), so maybe there are some important things you're doing there?

PS: I'm very impressed by your test coverage.

Also changed the ordering a bit, but still not satisfied
@LudwikJaniuk
Copy link
Contributor Author

@Marsup Would be nice to know how to do this ordering thing correctly. It seems that by making the ordering in objects kinda better, I ruined the ordering when the processed item is an array. Or something.

@Marsup
Copy link
Collaborator

Marsup commented Oct 17, 2016

I don't think the order matters much, maybe it would help you to have a look at the object before it's stringified as it contains all the placeholders that will be replaced, either that loop is wrong or the following one is.

It would be a lot easier and clearer to land those 2 features separately though if you don't mind.

Side-effect: Multiple references on one line will look slightly worse
than before, but it's still correct, and at least the bugs are gone.
Color-removal also works.
@LudwikJaniuk
Copy link
Contributor Author

Allright, the color stuff works and the refernces are now correct - the order is still suboptimal (actually a bit uglier in one case) but yes, that can be fixed in a separate PR.

@Marsup
Copy link
Collaborator

Marsup commented Oct 18, 2016

To have the correct order you'd need a more complex processing, that's not the goal of annotate, as long as you can pinpoint the errors it's fine. I'll check and report back.

@Marsup Marsup added bug Bug or defect feature New functionality or improvement labels Oct 18, 2016
@Marsup Marsup self-assigned this Oct 18, 2016
@Marsup Marsup merged commit 00e2f0c into hapijs:master Oct 18, 2016
Marsup added a commit that referenced this pull request Oct 18, 2016
@Marsup
Copy link
Collaborator

Marsup commented Oct 18, 2016

It's now published, thanks a lot !

@Marsup Marsup added this to the 9.2.0 milestone Oct 18, 2016
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug or defect feature New functionality or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error.annotate reference numbers are wrong
2 participants