Skip to content

Conversation

THardy98
Copy link
Contributor

@THardy98 THardy98 commented Mar 11, 2025

What was changed

Special behavior handling reserved temporal prefixes. Prevent users from:

  • registering activities, task queues, signals/updates/queries with a reserved prefix
  • calling default handlers with reserved names
  • going through interceptors when calling internal queries

Note: this change does not cover handling reserved temporal prefixes for workflows, as it involves non-trivial changes to the workflow bundling.

  1. Closes [Feature Request] Special behavior for Temporal built-in prefixes #1599

  2. How was this tested:
    unit/integration tests

  3. Any docs updates needed?
    I'm not sure.

@THardy98 THardy98 requested a review from a team as a code owner March 11, 2025 02:12
@THardy98
Copy link
Contributor Author

In this change, users are prevented from registering signals/updates/queries with reserved names from the handler.

Users can still defineQuery, defineSignal, defineUpdate that have reserved names. The reason for this is because we use defineQuery to create the reserved queries ourselves.

Alternatively, we can do the blocking in define<X> and create our internal queries/signals/updates using internal functions. Or we can do both (blocking in the define and the handler). I picked one because it seemed sufficient.

@THardy98 THardy98 force-pushed the handle_temporal_builtin_prefixes branch from 8170bc5 to 5f5103a Compare March 17, 2025 20:53
@THardy98 THardy98 changed the title [WIP] Special behaviour for temporal prefixes Special behaviour for temporal prefixes Mar 20, 2025
@THardy98 THardy98 changed the title Special behaviour for temporal prefixes [WIP] Special behaviour for temporal prefixes Mar 20, 2025
@THardy98 THardy98 changed the title [WIP] Special behaviour for temporal prefixes Special behaviour for temporal prefixes Mar 25, 2025
@THardy98
Copy link
Contributor Author

this is blocked on #1640 so we can handle the same prefix cases for updates as well

THardy98 added 3 commits June 16, 2025 18:20
… test needs to be fixed, need to add behaviour reserving prefixes from workflows, and waiting for default update to be merged to add behaviour preventing default update handler to be called with reserved names
@THardy98 THardy98 requested a review from mjameswh June 17, 2025 14:18
@THardy98 THardy98 force-pushed the handle_temporal_builtin_prefixes branch from 5f5103a to 8237158 Compare June 17, 2025 14:18
@THardy98 THardy98 force-pushed the handle_temporal_builtin_prefixes branch from 1a7b249 to 55c641f Compare June 17, 2025 18:27
@THardy98 THardy98 force-pushed the handle_temporal_builtin_prefixes branch from 9eb4558 to 452602f Compare July 23, 2025 14:03
@THardy98 THardy98 force-pushed the handle_temporal_builtin_prefixes branch from 452602f to 73823fa Compare July 23, 2025 14:17
@THardy98 THardy98 requested a review from mjameswh July 23, 2025 15:57
@THardy98 THardy98 force-pushed the handle_temporal_builtin_prefixes branch from d5428a3 to 059e3b6 Compare July 31, 2025 20:05
@THardy98 THardy98 requested a review from mjameswh July 31, 2025 20:34
@@ -1440,3 +1455,232 @@ test('Workflow can return root workflow', async (t) => {
t.deepEqual(result, 'empty test-root-workflow-length');
});
});

const reservedNames = [TEMPORAL_RESERVED_PREFIX, STACK_TRACE_RESERVED_NAME, ENHANCED_STACK_TRACE_RESERVED_NAME];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with what's here, but just giving some suggestions how you could have made those tests simpler:

  • It's not really important either the error message is "... with reserved prefix" or "... which is a reserved name", so you could have simply made that a regexp, like:
        {
          name: 'TypeError',
          message: /Cannot use activity name: .*/
        }
    
  • In the reservedNames array, you could have included __temporal_test (the composed form), instead of only the prefix; then, in tests below, you would no longer need the name === TEMPORAL_RESERVED_PREFIX ? name + '_test' : name expression.

@THardy98 THardy98 force-pushed the handle_temporal_builtin_prefixes branch from da9d57d to d686105 Compare August 1, 2025 03:54
@THardy98 THardy98 requested a review from mjameswh August 1, 2025 13:44
Copy link
Contributor

@mjameswh mjameswh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had one last thing, but fixed it myself.

Should be ready to merge now, just waiting for CI.

@mjameswh
Copy link
Contributor

mjameswh commented Aug 1, 2025

I had to also remove usage of the __temporal_logger sink in our internal tests, as well as in the deprecated defaultSinks() stub.

@THardy98 THardy98 merged commit a1d91be into main Aug 1, 2025
43 of 44 checks passed
@THardy98 THardy98 deleted the handle_temporal_builtin_prefixes branch August 1, 2025 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Special behavior for Temporal built-in prefixes
2 participants