fix: float32 formatting, CI alloc gate, CSP-nonced SSE pushes, sess.Clear(CtxR)#59
Merged
Conversation
float32 Signal/StateTab values were formatted at bitSize 64, so reflect.Value.Float widening leaked the float64 expansion (float32(0.1) -> 0.10000000149011612) into both the data-signals wire payload and the rendered DOM text. Branch on reflect.Float32 and format at bitSize 32 in encodeScalar and scalarString.
The allocation regression gate suffixed the bench invocation with `|| true`, swallowing its exit status, and turned a missing or unparseable benchmark into a WARN+skip. A renamed, broken, or panicking benchmark left CI green with the only perf guard silently disabled. Capture the bench exit status (any non-zero fails the gate) and make "benchmark not found" / "unparseable allocs/op" hard errors.
Under mw.CSP() every server-pushed script (Toast/Reload/ExecScript/ Redirect) was silently blocked: drainQueue emitted the datastar-injected <script> with no nonce. Capture the page document's CSP nonce at render (a dedicated read-only field) and thread it, HTML-escaped, into sse.ExecuteScript and sse.Redirect via WithExecuteScriptAttributes, so the push reuses the page nonce the loaded document's CSP honors.
sess.Clear handled only *via.Ctx and *http.Request; a *via.CtxR (which a View holds) fell through to a silent no-op. Add the missing *via.CtxR case mirroring Get, and correct the godoc that omitted CtxR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A batch of small, independent correctness fixes (each test-first, full
go test -race ./...+golangci-lintclean locally), plus a README line-wrap.Fixes
fix(encoding)—float32Signal/StateTabvalues were formatted atbitSize 64, soreflect.Value.Floatwidening leaked the float64 expansion (float32(0.1)→0.10000000149011612) into both thedata-signalswire payload and the rendered DOM. Now branches onreflect.Float32and formats atbitSize 32. Tests:TestStateTabText_rendersFloat32WithoutFloat64Noise,TestSignalEncode_float32WireValueHasNoFloat64Noise.fix(ci)— the allocation-regression gate failed open:|| trueswallowed the bench exit status and a missing/unparseable benchmarkWARN+skipped the gate, so a renamed/broken bench left CI green with the only perf guard disabled. Now captures the bench status and treats "benchmark not found" / "unparseable allocs/op" as hard errors.fix(csp)— undermw.CSP()every server-pushed script (Toast/Reload/ExecScript/Redirect) was silently blocked, because the datastar-injected<script>carried no nonce. The page document's CSP nonce is now captured at render (a dedicated read-only field, never lazily minted) and threaded — HTML-escaped at the sink — intosse.ExecuteScript/sse.Redirect, reusing the page nonce the loaded document's CSP honors. First coverage of the interactive SSE path under CSP (csp_push_test.go).fix(sess)—sess.Clearaccepted only*via.Ctx/*http.Request; a*via.CtxR(held by a View) fell through to a silent no-op. Added the missing*via.CtxRcase mirroringGet, and corrected the godoc. Test:TestClearSess_viaCtxRRemovesValue.docs(readme)— wrap prose to 80 columns (matchingCONVENTIONS.md) and tidy section headings.Rebased onto current
main(post-#57/#58); no overlap with thevia.sse.disconnectreason-label work.