Repository navigation
Conversation
- Server: one `_finishResponse` for both `_processAPIResponse` branches; helpers renamed to what they do (`_buildShelfResponse`, `_disposeAndCompressResponse`, `_startServersAndInitializeAPIRoot`, `_errorResponse`); CORS set once; payload reading shared (`_readPayloadBytes`, `_toUint8List`, one `maxPayloadLength` check); `_flattenSingleValues` for headers and query parameters; header names and the session cookie as constants; `normalizeHeaderValue` passes `k3`. - Security: one `resolveMapped` chain in `_resolveRequestCredentialsTokens`; dispose methods share `_disposeFromTokenStore`; `_setRequestCredential`. - Root/module: `_resolveModuleOrDefault`, `APIRoot.apiInfoRoute` and `APIRoot.defaultAuthenticationRoute`; `_routesHandlersPATCH`. - Response cache: an entry evicted once (not per alternative); `ifModifiedSince`; `void` 304 store; one `GET` check. - Cron: `_execute` split into `_runCalls`, `_storeRunResult`, `_runLabel`. - Mixin: `_findKeyByNormalized` for the lower-case and simple lookups. - Cache fields named `*Cache`, documented and declared before their users. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…unting - `_checkMaxMemorySize` sorted `_cachedResponses.values`, which holds a `List<_CachedResponse>` for an entry with compressed alternatives (not `Comparable`): a `TypeError` on eviction. It now sorts the entries (key + all alternatives), compared by their total usage and memory size (`_CachedResponse.compareEntries`, same order as `compareTo`). - `_expire` removed the entries (200 and its 304) from the map directly, so their memory size was never subtracted from `totalMemorySize`: now through `_remove`. Tests: eviction of JSON responses with gzip alternatives; total memory back to 0 after the cached entries expire. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- `_getUserDirectory` fell back to `Directory('~/')`, a literal `~`
directory (relative to the current one), not the home directory. The home
is now resolved only from `HOME`/`USERPROFILE` (Windows first tries
`USERPROFILE`, the others `HOME`, each with the other as fallback), in
the new `APIServerConfig.resolveUserDirectory` (`@visibleForTesting`).
The identical macOS and Linux branches are merged.
- `_resolvePayloadFromString`: `catch (e, s)` shadowed the payload `s`, so
the JSON-decode error log printed the stack trace in place of the
payload: now `catch (e, stackTrace)`.
Tests: `resolveUserDirectory` (incl. a literal `~` directory in the
current directory being ignored); the decode error log shows the payload.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It bucketed elements by `hashCode`: an element whose `hashCode` changed after being added was looked up in another group, so `contains`, `add` and `remove` missed it. An identity set now uses `identityHashCode`. Test: an element with a changing `hashCode`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It passed the caller's `fieldLC`/`fieldSimple` (the normalized forms of ONE field) to the lookup of every field, so all the fields after the first matched that same key. They are now computed per field; the two parameters are kept (public API) but ignored and `@Deprecated`. The `mapLC` and `mapSimple` indexes (per map) are still shared by all the fields. (No caller in the package passed them.) Test: two fields with `fieldLC`/`fieldSimple` and shared indexes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #206 +/- ##
==========================================
- Coverage 95.85% 95.84% -0.01%
==========================================
Files 75 75
Lines 26519 26504 -15
==========================================
- Hits 25419 25403 -16
- Misses 1100 1101 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Author
|
Merged into the single v1.35.0 PR: #209. |
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.
Clean-up of the API/server layer (server, security, root/module, response cache, cron scheduler, mixin, session, utils), plus six bug fixes, each with a test. Entity, condition, SQL and adapter files are not touched (parallel PRs).
Refactors (behavior-preserving)
_processAPIResponsebranches end in one_finishResponse(the nested branch still disposes the outer response after building theResponse, same order). Renamed:_sendAPIResponse→_buildShelfResponse,_processResponse→_disposeAndCompressResponse,_startImpl2→_startServersAndInitializeAPIRoot,_errorProcessing→_errorResponse._resolveAPIResponseHeadersno longer repeatssetCORSwhen!hasCORS.setCORSis deterministic and idempotent (it assigns the same values;Varyis merged without duplicates), so the repeated call changed nothing. The only code between the two calls is body resolution, which doesn't touch CORS headers._readPayloadBytesand_toUint8Listare shared;maxPayloadLengthis checked once, before allocating; a singleUint8Listblock is still not copied.toAPIRequest:_flattenSingleValuesbuilds both headers and query parameters; it uses the localrequestedUri;APIServer.sessionIDCookieNameis used at all three sites.APIServer.headerXAccessToken(security uses its lower-case form, so the exact-match precedence of the alternatives is unchanged),headerServerTiming,headerKeepAlive,headerContentLength,headerXAPIServerWorker, andHttpHeaders.wwwAuthenticateHeader. Lookups stay case-insensitive.resolveMappedchain in_resolveRequestCredentialsTokens(stays sync when each step is sync). ThedisposeAuthentication*pairs share_disposeFromTokenStore/_disposeCredentialFromTokenStore._setRequestCredentialis extracted, and the redundantallowLogout &&is dropped._resolveModuleOrDefault;APIRoot.apiInfoRouteandAPIRoot.defaultAuthenticationRoutereplace the literals (incl.apiInfoURL);_routesHandlersPATH→_routesHandlersPATCH.normalizeHeaderValuepassesk3toapiConfig.getPath. Existing callers pass nok3; a test was added.requestIfModifiableSince→ifModifiedSince(all private); the 304 store is avoidfire-and-forget_storeResponse304; theGETcheck is done once incacheResponse._executeis split into_runCalls,_storeRunResultand_runLabel. Await order and catch placement are unchanged._findKeyByNormalizedis shared by the lower-case and simple-key lookups.*Cache, documented, and declared before their users. Server:_responseCompressionCache(now also used by_createDirectoryHandler),_directoriesStaticHandlersCache. Base:_securityModuleCache,_securityCache/_securityCacheResolved,_hostnameCache,_portCache,_requesterAddressCache,_originCache. Module:_securityCache. Session:_sharedSessionsCache,_sharedMapCacheTimeout. Utils: doc for_toLowerCaseSimpleCache.Bug fixes (each in its own commit, with a test)
TypeError:_checkMaxMemorySizesorted_cachedResponses.values, which holds aList<_CachedResponse>for an entry with compressed alternatives, and aListis notComparable. Entries are now sorted with all their alternatives, by total usage and memory size (_CachedResponse.compareEntries, same order ascompareTo). Test: evicting JSON responses that have gzip alternatives._expireremoved entries without subtracting them fromtotalMemorySize; it now goes through_remove. Test: the total goes back to 0 after expiry.Directory('~/')is a literal~folder, not the home directory. The home is now resolved fromHOME/USERPROFILEonly, in the new@visibleForTestingAPIServerConfig.resolveUserDirectory; the identical macOS/Linux branches are merged. Test included.catch (e, s)shadowed the payloads, so the log printed the stack trace instead of the payload. Nowcatch (e, stackTrace). Test: the log record contains the payload.IdenticalSetgrouped elements byhashCode; it now usesidentityHashCode. Test: an element whosehashCodechanges.getFieldsKeysInMappassed one caller-providedfieldLC/fieldSimplefor every field. They are now computed per field; the parameters are kept (public API) but ignored and@Deprecated. No caller in the package passed them. Test included.The version is bumped to 1.35.0 (pubspec +
BonesAPI.VERSION) because 1.34.0 is already tagged; the CHANGELOG section is started.Tests run locally
dart format .(clean) anddart analyze --fatal-infos(no issues).dart test -x dockeron: cov_server_http, cov_server_config, bones_api_test, cov_error_zone, cov_security, security_vm, authentication, cov_authentication, cov_root, cov_module, cov_base, cov_server_cache, cron, cron_db_memory, cron_server, cov_pool_weaklist, session, mixin, utils, utils_collection: 469 passed.The new cache, IdenticalSet and getFieldsKeysInMap tests were also run against the pre-fix sources, where they fail.
🤖 Generated with Claude Code