Repository navigation
Conversation
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4904/ |
f6ddc05 to
8a2df0c
Compare
The endpoint's hand-written IsValidPageFeedback becomes ten named rules on PageFeedbackRequest, which now lives in the domain assembly. A differential test holds the rules to the old check for 3,000 generated requests. The endpoint still answers a bare 400. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Main added OpenAPI examples that import PageFeedbackRequest from the Api namespace. This branch moves the type to Elastic.Documentation.PageFeedback, so the merge no longer compiled. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
8a2df0c to
fb53e8d
Compare
AutoTest runs every rule over generated legal requests at the boundary of each limit and proves each rule can fire. A second generator adds blank and over-long text, nulls, undefined enum values, mismatched and duplicate reasons and out-of-range versions, and checks that no rule throws. It found no defect. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… wording The legal generator filtered through the rules under test, so a rule that rejected a legal boundary value would have dropped the case silently. It now selects with the old hand-written check. The comments on the rules and the endpoint said "bare 400"; the endpoint answers a generic invalid-arguments problem. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Keep every InternalsVisibleTo entry and the union of the domain namespaces in DomainPurityTests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
| reason is PageFeedbackReason.Inaccurate or PageFeedbackReason.MissingInformation or PageFeedbackReason.HardToUnderstand or PageFeedbackReason.CodeSampleErrors or PageFeedbackReason.OutOfDate or PageFeedbackReason.AnotherReason, | ||
| _ => false | ||
| }; | ||
| !request.Check("page-feedback").Findings.Any(d => d.Severity == Severity.Error); |
There was a problem hiding this comment.
Severity: P3 (Low)
The endpoint now builds a full report even though it only needs a yes/no verdict. A request with a missing reason-set version still walks its entire reasons list if the entries fit the reaction; the previous validator rejected it before walking the list. Keep the named rules, but preserve fail-fast validation for this caller so work on already-invalid requests does not scale with the reasons list.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
There was a problem hiding this comment.
Not changing. The response is identical (the generic 400, locked by the page-feedback-validation S8 snapshot). The only difference is that a request with reasons but no version is walked once, linearly (Enum.IsDefined per entry), before being rejected, instead of rejected in O(1). The old validator also walked the whole list for any request with a version, and the body size is already capped by the host, so this is not a scaling risk. Keeping the named rules as a single pass is the design of this PR; fail-fast ordering would need a rule-ordering feature in Nullean.Entities.
…read The API only uses public Check, so Configuration internals stay hidden from it. The sample callback mutates a shared set and counter, which is unsafe under concurrent iterations. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The page feedback endpoint's validation becomes ten named rules on
PageFeedbackRequest. Accepted and rejected requests, and the 400 answer (today's genericapplication/problem+jsontitled "Invalid arguments", with no field names), stay the same.Affects: Internals only
Stack: 16 of 16 in the split of #4530, on top of the foundation #4888.
Why
IsValidPageFeedbackis one long boolean expression, so a rejected request cannot say which rule it broke and the rules cannot be listed or tested one by one.What
Rules in the domain
PageFeedbackRequestand its two enums move toElastic.Documentation.PageFeedback, unchanged apart from implementingIHaveConstraints.PageFeedbackRequestConstraintsdeclares ten rules: URL present, short, a local path; title present and short; reaction thumbs up or down; comment short; reasons come with a version; a comment needs reasons; reasons fit the reaction. The JSON contexts and wire format are unchanged.Endpoint
IsValidPageFeedbackchecks the request throughCheckand returns false on any error. The response stays today's generic400application/problem+json("Invalid arguments", no field names).Checkdoes not catch exceptions, so a rule that threw would still fail the request as the old check would; the differential test covers hostile values and none throws.Configurationmakes its internals visible to the API assembly forCheck. Consumers only gain ausingfor the new namespace.Tests
A differential test holds the rules to the old hand-written check, kept in the test as the specification, for 3,000 generated requests with hostile values. Example tests name the rule and field each breakage hits. The existing
.httpsnapshots of the endpoint did not change.Deferred behaviour changes
application/problem+jsonthat names the offending field (main's problem+json is generic: "Check pageUrl, pageTitle, reaction, reasons and comment.") (Nullean.Entities.AspNetCore).Verify
No verified snapshot changed. Golden site build compare skipped: API only, no site build path.
🤖 Generated with Claude Code
Found by generated data
Nothing: no rule throws on hostile requests and all ten rules can fire.