fix(admin): widen onMessagePublishedEffect runtime to include schema DecodingServices - #124
Open
detail-app[bot] wants to merge 1 commit into
Conversation
|
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.
Detail bug report: View on Detail
Closes #105
Bug
onMessagePublishedEffect's schema-bearing options typeMessagePublishedEffectOptionsWithSchema<R, S>extendedMessagePublishedEffectOptions<R>without wideningRto include the schema'sDecodingServices(S['DecodingServices']). Every other background trigger-with-schema wrapper —onTaskDispatchedEffectand the four Firestore triggersonDocumentCreated/Updated/Deleted/WrittenEffect— widens the runtime contract toR | S['DecodingServices'], so a schema whose decoding requires a Context service can't be paired with a runtime that omits it.onMessagePublishedEffectwas the lone exception: amessageSchemawith non-neverDecodingServicestype-checked against an insufficient runtime, then at runtime decoding died on the missing service, the wrapper loggedDefect in onMessagePublished, and the message was ACKed unprocessed.Fix
Widen the options type to match the sibling background triggers (one line in
packages/admin/src/lib/functions/on-message-published.ts):The implementation cast (
as Effect.Effect<void, never, R>at line 121) is unchanged, mirroringon-task-dispatched.ts:106— the implementation signature only bindsR, soSisn't in scope there, and the overload options type is the public contract callers are checked against. Schemas withDecodingServices = never(the commonSchema.Structcase, plus the in-repotransformEffectschemas that only useEffect.succeed/Effect.fail) are unaffected:R | never === R.Testing
on-message-published.spec.ts: a service-boundmessageSchema(aSchema.String.decodeTowhosetransformEffectreads aDecoderServiceContext service) is paired with both a sufficient and an insufficient runtime. A@ts-expect-erroron the insufficient-runtime call asserts the compile-time rejection; a runtime test publishes a message through the sufficient runtime and asserts the handler receives the decoded (DecoderService.transform-applied) value.@ts-expect-errorguard was bisimulation-checked: reverting the fix turns the directive intoTS2578: Unused '@ts-expect-error' directive(the buggy code compiles cleanly); removing the directive with the fix applied surfacesTS2769: No overload matches this call—ManagedRuntime<never, never>is not assignable toRuntime<DecoderService>— the same error shape the siblingonTaskDispatchedEffectproduces.on-task-dispatched.tsand the four Firestore triggers still rejects the identical insufficient-runtime setup; the fix doesn't touch them.Schema.Struct({ userId: <service-bound leaf> }), which inherits the service requirement throughStruct.DecodingServices<Fields>and produces the same compile-time rejection.messageSchemastill resolve to the second overload (MessagePublishedEffectOptions<R>, no widening).nx run @effect-firebase/admin:build, eslint, and prettier. The CI gatenx affected -t lint test buildsucceeds for the affected projects.Automatic Fixes PRs can be configured here.