mountebank icon indicating copy to clipboard operation
mountebank copied to clipboard

Warn on unrecognized fields

Open bbyars opened this issue 5 years ago • 5 comments

Add validation that logs a warning on all unrecognized fields. This allows them to pass those fields, but gives some additional feedback for when they've put it in the wrong spot or mistyped it.

We'll need some sort of schema to validate against. I'd previously explored writing node-defacto to create a schema based on tests.

bbyars avatar Jun 25 '19 13:06 bbyars

Can you assign me to this issue? I would like to help resolve it.

SabrinaAde avatar Feb 26 '22 23:02 SabrinaAde

Done!

bbyars avatar Feb 28 '22 00:02 bbyars

Could you give a little bit more explanation on the ticket for this issue. I am not sure if you just want me to write on top of the node-defacto code you already have written or use something completely different . And just to clarify this program needs to be able to run on mountebank correct? And the warning log should appear when code sees fields that the test double isn't expecting when it's called?

SabrinaAde avatar Mar 01 '22 01:03 SabrinaAde

Hi there, I haven't touched node-defacto in some time, so I'm not at all committed to using it. To be honest, I have not had a deep thought on how to solve this one. If you have an idea, I welcome your suggestions!

A richer definition of the problem is this: On the one hand, mountebank should allow users to add any custom fields they want when sending REST bodies. That lets them add things like comments or fields for custom protocols. On the other hand, what that means, is that when a user mistypes a field or puts it in the wrong place in the JSON hierarchy, it just seems to them that mountebank is ignoring it, and the lack of any warning slows down their troubleshooting.

So what I think needs to happen is that, on every HTTP call with a body field mountebank doesn't recognize, it does a logger.warn() statement to let the user know it is intentionally ignoring that field. That still leaves questions about whether all unrecognized fields should be logged together or one at a time, and the short answer is I don't know off hand but both are better than nothing. I think it would require some trial and error to investigate how hard a single-line log of all unrecognized fields is and what gives the developer the best troubleshooting information without overwhelming them.

So yes, mountebank should still run. Does that help?

bbyars avatar Mar 05 '22 21:03 bbyars

Yes! Thank you for the detailed explanation it helps a lot. I just started working with open source so I'll be taking my time working on this project. I'll keep you posted on how it goes and if I have any further questions.

SabrinaAde avatar Mar 06 '22 23:03 SabrinaAde