Replies: 6 comments 13 replies
-
Cross posting the gist of my last comment from the linked issue for reference Still digesting and thinking on this one, but wanted to note that I look forward to the discussion and hopefully being able to decide on a direction. There's been different and yes some times conflicting prescriptions on the "how strict/loose" topic, and it was one of the more confusing, and occasionally frustrating, things for me when I first started contributing to Shields. Ultimately I don't care all that much about what the decided outcome is, but really want to avoid contributors receiving different messages depending on which maintainer is reviewing (and what may be on that maintainer's mind that day), or which docs/existing badges are used as a reference. |
Beta Was this translation helpful? Give feedback.
-
@chris48s - my takeaway theme from the guiding points you've articulated would be:
I think in general I can get behind that strategy, although I do still think there's merit to having stricter schemas that surface incorrect assumptions by failing more loudly/obviously. I don't have a good example offhand, but my sense is that we've had our fair share of bugs that were more easily debugged due to the The most important outcome of this discussion from my perspective is that we document the agreed upon strategy, and use/enforce that going forward (as well as adjusting existing non-compliant schemas over time). Perhaps I'm wrong, but I'd posit there's a mix of both ends of the schema strictness scale today and that there are plenty that are overly strict in the context of this proposal, and that they did not get there iteratively but were instead born very tight/strict. |
Beta Was this translation helpful? Give feedback.
-
Will have a think as well, but reading through your principles makes sense to me so far @chris48s ! |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I thought the tone of this draft was fairly light-hearted tbh. Maybe it needed more emoji
Guidance is good. Writing down what we do and why we do it is helpful. I fully agree with this - hence having bothered to spend time on this exercise so far. I suspect I will spend a fair chunk more time on it before we're done with this. Being too rigid about enforcing that guidance, not so much. I guarantee at least one of the things I've written here sounds reasonable now but will turn out to be wrong in the face of a sensible example. Feel free to be the person that provides it. FWIW, I think this process should be mostly about describing the good practices we've learned from writing hundreds of these things and learning from our mistakes rather than defining a swathe of changes we're going to apply to make everything "compliant". Obviously I've not read every single one of the hundreds of schemas we've already defined and I'm sure there's some weird stuff in there, but I reckon the vast majority are already somewhere inside the "window of sensible-ness".
Anything in this thread helping with that, or not really?
Got any particular examples of that? If you can't bring any to mind, no worries, but if we've got some examples of the kind of situation we're trying to clarify or inconsistency we're trying to prevent then that is going to be a big help in writing the docs that are supposed to clarify it. |
Beta Was this translation helpful? Give feedback.
-
Completely agreed, and that's why I picked it. We've had a few previous reports about
Yup, i think color would indeed fall under the "correct" umbrella we've been discussing here in addition to the message. So while yes, badges in the build status category would relatively have stricter schemas, the reason is because it's needed to ensure proper coloring of the badge. That being said, there's obviously a coloring aspect. to version badges too. Many (most, all?) use the version helpers which also have some assumptions about the contents. I guess the difference here is that a version would have to be pretty wild (starting with something bonkers like shields/services/color-formatters.js Lines 9 to 23 in ff9273a |
Beta Was this translation helpful? Give feedback.
-
See longer conversation in #5597 (comment)
Some suggested principles for input validation:
Our definition of "valid" should be no stricter than the upstream service's definition of "valid". Perhaps to phrase this in RFC-like language: "our validation MAY be less strict than the upstream service but MUST NOT be more strict than the upstream service". Exactly where in that grey are we fall is going to be determined by other badge/service-specific criteria/requirements.
If theory (docs) and practice (real-world API responses) conflict, real-world outputs take precedence over documented behaviour. e.g: if the docs say
version
is a semver but we learn that there are real-world packages where the version number is0.3b
or1.2.1.27
then we should accept those values in preference to enforcing the documented API behaviour.Shields is descriptive ("the registry says your package version is 0.7, therefore your package version is 0.7") rather than prescriptive ("you're doing versioning wrong - lol"). We reflect the established norms of the communities we serve. If it's good enough for the upstream, it's good enough for us.
Some other thoughts on principles we can apply. Maybe these ones are more about how we identify when validation that already exists is incorrect rather than how we write schemas from scratch:
If we know of a real-world example of a package/repo/etc that causes us to render an error value on a badge (e.g: etc), our input validation is broken and we should fix it.
If we know of a real-world example of a package/repo/etc that causes us to thrown an unhandled runtime exception, our input validation is broken and we should fix it.
We should not fail to render a badge because of a validation failure on a field that isn't necessary to render the badge. (for example, a version badge should not fail to render because the license field is missing). It is not inherently wrong to define a single schema which is applied to multiple badges. For example, its fine in principle to define a schema that says
for a shared helper and have both the license and version badges validate the response against that schema. However, if we become aware of a real-world example of a package/repo/etc that has a
version
key but not alicense
key then we should split the schema (or makeversion
optional and handle the error in code). Maybe we know that at schema creation time (e.g: because its documented), or maybe we don't find out until some later point in time (because we have a real-world example of it happening via a support request).Would welcome input from other maintainers...
Beta Was this translation helpful? Give feedback.
All reactions