Skip to main content

.NET Debugging and Observability

Install the generated Debug Assist's SafeSqlEvidenceSink as the trusted IDiagnosticSqlLogSink. It retains a bounded, value-free projection while the wrapped text sink remains operator output.

var evidence = new SafeSqlEvidenceSink();
context.WithDiagnosticSqlLogSink(evidence);
context.EnableQuerySqlLog();
evidence.Clear();

var rows = await Q.Schools().Limit(20)
.Comment("Diagnose the school search")
.Purpose("Verify filters, facets, and relation loading")
.ExecuteForListAsync(context);

IReadOnlyList<SafeSqlEvidence> safe = evidence.Snapshot();

Use EnableQuerySqlLog(), DisableQuerySqlLog(), EnableMutationSqlLog(), and DisableMutationSqlLog() independently. Passing null to WithDiagnosticSqlLogSink removes operator output. DebugQuery must never enter HTTP responses or ordinary telemetry.

Run the Facet, aggregate, deep relation, Top-N, and audited save examples from .NET advanced data operations. Compare typed trace, parameterized SQL, duration, result/affected counts, and aliases while preserving native validation, conflict, and provider failures.

Install telemetry with context.WithRuntimeTelemetry(telemetry). Raw provider audit is independent from the safe IAppAuditEventSink. The current IRequestPolicy applies to queries; mutation tenant authorization must also be enforced and tested at the application/provider/TFP boundary.

Finish with the shared checklist.

Order troubleshooting​

For the full operation and recovery sequence, use the C# / .NET mutation recipes: deletion, state changes and version conflicts.

Start with the C# / .NET Order tutorial and API usage guide. Diagnose the first native error before changing a dependency or rerunning a suite. Compare the failing runtime, model and fixture against the authority for that operation.

SymptomWhat to inspectNext action
ORDER_OK is printed but the wrong Order is visibleAbsolute database path, model revision and selected fixture.The first-edit fixture has three Orders; pagination and insights use separate nine-/ten-order fixtures. Keep each in its own database and use business keys, not copied numeric IDs.
Empty result or duplicate business identityQuery cardinality and scoped predicates.Keep the expected-one check. An empty result is distinct from a provider exception. A buyer filter alone does not authorize a tenant.
Wrong total or omitted item after editFull scalar/relation loading, item bounds and money validation.Reload the complete bounded collection before calculating totals; a preview is not a full edit graph and omission is not deletion.
TeaQLNotLoadedException while reading an optional fieldThe field was not selected; this is different from a selected nullable result.Select the field before Eval() or the null-only default. Do not catch NotLoaded and substitute SQL NULL.
Invalid cast while reading aggregate resultsAnalytic Record fields contain TeaQL Value wrappers.Use TryF64()/TryText() as shown in the recorded School and Order examples; do not cast wrappers through Convert.
A retained-ID hit uses an unexpected filtered setThe recorded compound-condition key repair or its installed NuGet artifact is missing.Compare the exact source/package/installed-assembly identities in the receipt. That repair remains WORKSPACE PASS — RELEASE PENDING.
Connection is disposed before an edit finishesAn async save outlived the owned connection scope.Await the audited save before leaving await using. Keep transaction disposal and cancellation inside the native execution boundary.
A pool count is assumed from a connection closePooling and a connection object’s State are different observations.The soak example explicitly uses Pooling=False and verifies native Closed state plus transaction disposal. Scope that evidence to its setup rather than assuming identical pooling behavior everywhere.

Order query troubleshooting​

Use C# / .NET Order Queries with the matching export/insights fixture and recorded workspace. Diagnose the native plan and result carrier before changing an optimizer, cache or numeric conversion.

SymptomWhat to inspectNext action
Export count is 9 instead of 8Export uses a buyer-only predicate; the ten-order fixture adds an export-buyer EUR control.Use the nine-order export database. Retained-ID and summary recipes deliberately use the ten-order database and a currency predicate.
Empty export tail looks like failureThe ascending export's final offset 9 reports CACHE_MISS, zero rows and exact total 8.Stop on the empty tail normally. For retained IDs an empty tail can instead be an ID_SET_HIT.
ID overflow shows 5 while total is 8Capacity 4, lower-bound scan and exact provider COUNT.Keep observedCount separate from the matching total; do not retain a partial set or present 5 as the exact count.
Grand total equals a page/preview sumParent page size, child preview size and predicates on every aggregate/Facet request.Aggregate the whole filtered set in the provider. In the all-USD fixture it is 8/35350, even though only three parents are visible.
Empty sum or zero buckets are unexpectedEmpty groups, the one-row overall aggregate, and include-all versus matched-only Facets.Preserve overall count 0/sum null; keep zero status buckets only for the requested all-status variant.
Another buyer’s retained set is returnedThe existing compound-condition query-key repair or its exact installed artifact may be missing.Compare source, NuGet and assembly identities with the receipt. The repair stays RELEASE PENDING and also affects continuous keys; removing a predicate or clearing all state per page is not a key fix.
Convert fails on an aggregate or an empty sum throwsFields in analytic .Rows are TeaQL Values; native status key is order_status.Use TryF64()/TryText(). The non-null N(Value) helper is for nonempty group values; preserve nullable overall sum.
Store invalidation races a queryThe wrapper uses the actual observed key and async InvalidateAsync.Await completion and reuse the sequence’s context/store; do not fire-and-forget invalidation then claim the next page was rebuilt.

Read the plan immediately after its request; a namespace string or stale observation from another request is not proof of reuse. The existing query cases record actual provider SQL, keys, builds/hits, elapsed expiry/invalidation events and unchanged database snapshots. Use that evidence first. Fixed-data reads do not supply a concurrent-write snapshot or a distributed-cache guarantee. All original runtime pending-release and generator-deployment qualifications remain.

Order isolation troubleshooting​

Use C# / .NET Order Isolation with the v1.1 model/library and fresh eight-order database. Inspect the facade boundary and actual provider predicates before broadening access or changing a cache namespace.

Symptom / codeWhat to inspectNext action
Wrong model or missing tenant-key APIv1.0 core/query workspace versus the v1.1 isolation library, manifest and database.Use the retained regenerated isolation set; this is a fresh-database tutorial, not a live migration. Do not hand-edit generated files.
UNAUTHENTICATED / FORGED_SCOPEServer-owned session resolution and identity/policy fields in business JSON.Keep client fields out of the session tuple; the fixture key is not a production credential.
INVALID_TRUSTED_SCOPEZero/multiple tenant roots for the resolved key.Fail closed and repair provisioning; never choose an arbitrary root.
Foreign ID gives NOT_FOUNDRoot + buyer predicates and parent-owned item resolution.Preserve the common missing/foreign response; do not make a public unscoped lookup to distinguish them.
INVALID_BOUNDS, FORBIDDEN_FIELD, FORBIDDEN_OPERATIONNative numeric type, exact patch keys and read-only actor.Use integer 1–2 and the exact note/label patch. Do not coerce identity, strip extra fields or partially save.
List is scoped but summary/cache is notSame trusted predicates on every aggregate and retained request.Expect count 2/7700 cents; cache a,b,c,a must BUILD,BUILD,BUILD,HIT on one context with distinct scope identities.
Child edit reads a partial graph or changes unrelated versionsThree-child sentinel, two-child supported bound and native save path.Detail/edit overflow returns ITEM_LIMIT; preserve scoped complete-state loading and compare unrelated rows.
Cache scope differs despite the same package labelRetained compound-predicate identity needs the recorded condition-key runtime and exact installed assembly.Keep its workspace qualification, native FilterByCommercePlatform, .Rows/.TotalCount and awaited scalar reload/save.
Audit actor or HTTP authorization is assumed from response metadataThe example tuple is separate from native context principal and transport authentication.Wire real authenticated membership/principal mapping at the service boundary. JSON actor metadata and an audit reason do not prove that integration.

The isolation receipt checks the named console requests with SQL and SQLite snapshots. It does not certify arbitrary raw Q/database access, exhaustive hostile JSON, production migration or authorization revocation during a save. Keep runtime and generator release marks from the API scope guide.

Read the evidence in order​

QuestionExisting authority
Query shape, null state, edit, page or analytic resultCore Order receipt, this language’s native source, and the selected fixture.
Stale winner or atomic child failureConcurrent writes and the stored unchanged/authoritative database snapshots. Busy/locked and timeout errors do not qualify as version conflicts.
Request cancellation, provider statement failure or real COMMIT failureLifecycle evidence. Preserve the native error and verify rollback before retry.
Transaction, connection or task ownership after drain/closeFinite soak evidence. Separate active leases from idle owned connections and verify the final native close/lifetime end.
Published package differs from a recorded workspace PASSRelease qualifications. Keep the pending-release marker and exact runtime source/package identity.

Collect the failing phase, native error type/message, model and fixture revision, resolved runtime/package identity, and parameterized SQL shape/affected rows. Keep raw parameters and rendered SQL in the trusted operator boundary. Runtime telemetry sampling is not proof that an audit event was delivered or a transaction committed.

Reuse the existing failure and successful recovery evidence first. If a specific claim still has no authority, isolate that one operation on a disposable database and record the minimal result. Keep that reproduction scoped to the failing operation. Preserve School, every historical Order receipt, all six lifecycle/soak workspace pending-release qualifications, and the generator repairs pending deployment.

This language’s recorded advanced Order result remains WORKSPACE PASS — RELEASE PENDING.