Title: fix(knowledge): align document tag provenance selections with the serialized request by waleedlatif1 · Pull Request #6332 · simstudioai/sim · GitHub
Open Graph Title: fix(knowledge): align document tag provenance selections with the serialized request by waleedlatif1 · Pull Request #6332 · simstudioai/sim
X Title: fix(knowledge): align document tag provenance selections with the serialized request by waleedlatif1 · Pull Request #6332 · simstudioai/sim
Description: Problem Same bug class as the selectTableRowSecretProvenance outage fixed in #6325: a private-provenance producer counting pre-serialization semantics while the consumer counts post-serialization. Knowledge document writes (knowledge_create_document, knowledge_upsert_document): Producer — selectKnowledgeDocumentWriteSecretProvenance counted one name/value selection pair per parseDocumentTags entry. parseDocumentTags keeps an entry whose value is merely truthy, then coerces value: String(entry.value). Consumer — parseKnowledgeDocumentTagProvenanceTargets builds targets from the serialized documentTagsData and drops entries where value === ''. resolveKnowledgeWriteSecretProvenance rejects the write with HTTP 400 when bundle.selections.length !== selectionKeys.length. So any tag value that is truthy before coercion but stringifies to empty — [], [null], [undefined], an object whose toString() returns '' — was counted by the tool and dropped by the route. Reproduced by executing both parsers against [{ tagName: 'kept', value: 'value' }, { tagName: 'dropped', value: [] }]: the tool emitted 6 selection keys, the route derived 4. Not observed in production logs — found by code-level audit. Semantics Drop, matching the route. The functional write path agrees already: resolveDocumentTags skips any tag whose value fails its hasValue check, so an empty-stringifying tag never persists a value and has nothing to attribute provenance to. Fix Following the update_chunk pattern (its selector mirrors its own body builder exactly), the producer now describes exactly what goes on the wire: it runs the same formatDocumentTagsForAPI(parseDocumentTags(...)) the body builder runs, then feeds the resulting documentTagsData through the same target parser the route uses. parseKnowledgeDocumentTagProvenanceTargets moved from lib/knowledge/secret-provenance.ts (which pulls in @sim/db) to the db-free lib/knowledge/secret-provenance-selection.ts both sides already import, so there is one parser, not two rules that can drift. Tests apps/sim/tools/knowledge/secret-provenance.test.ts asserts the tool's selection keys equal the route-derived target keys for each divergent value, plus a non-divergent case. Verified red before the fix (expected 6 keys to equal 4), green after. Audit of the other provenance producer/consumer pairs Pair Status knowledge document tags fixed here table rows (selectTableRowSecretProvenance ↔ createTableWriteProvenanceTargets) Aligned since #6325. Residual theoretical gap: the producer filters only undefined, but JSON.stringify also drops function- and symbol-valued keys, which the consumer's Object.entries over the parsed row would then not see. Not reachable from JSON-sourced tool params — left alone. workspace files (file_write, file_append) Fixed arity ['content'] on both sides. memory (memory_add) Fixed arity 1 on both sides. knowledge chunks (upload_chunk, update_chunk) Fixed arity; update_chunk's conditional producer mirrors both its body builder and the route's validatedData.content === undefined check. workflow executor Fixed arity 1 on both sides. Checks bunx tsc --noEmit -p tsconfig.json — clean bun run lint — clean (9 pre-existing unrelated warnings) app/api/knowledge/secret-provenance.test.ts + new test — 14 passed tools/knowledge/knowledge.test.ts fails identically on a clean checkout (postcss/tailwind env issue), unrelated
Open Graph Description: Problem Same bug class as the selectTableRowSecretProvenance outage fixed in #6325: a private-provenance producer counting pre-serialization semantics while the consumer counts post-serialization. ...
X Description: Problem Same bug class as the selectTableRowSecretProvenance outage fixed in #6325: a private-provenance producer counting pre-serialization semantics while the consumer counts post-serialization. ...
Opengraph URL: https://github.com/simstudioai/sim/pull/6332
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:3e7bce20-6201-4fca-9b96-86bf82857f32 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E406:3FAE84:A8A6FD:E7CCA0:6AFB50AF |
| html-safe-nonce | 876132df73b210807a18ce0fd21860ec17a4fdc4c993b7c06a645703a4923e00 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNDA2OjNGQUU4NDpBOEE2RkQ6RTdDQ0EwOjZBRkI1MEFGIiwidmlzaXRvcl9pZCI6IjcxNjI1NjEwMzY4NDEzNDExMDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 43e3c2ca16b4bcd7c85bc1fedfd9b00147e2cf0c8ded1d8d6ae9478059718c9c |
| hovercard-subject-tag | pull_request:4223266325 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/6332/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | Problem Same bug class as the selectTableRowSecretProvenance outage fixed in #6325: a private-provenance producer counting pre-serialization semantics while the consumer counts post-serialization. ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7122bb414b542dba14d71a3f0b9f6fd2abce715b9f5912d082800563e6c806d1 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cbf66c024bb6d10e6955baa7413c54cf13a201bb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width