Skip to content

Fixes #37191: Use the two-argument buildEntityUrl example - #37194

Merged
manerow merged 2 commits into
mainfrom
fix/37191-build-entity-url-example
Nov 6, 2026
Merged

manerow merged 2 commits into
mainfrom
fix/37191-build-entity-url-example

Conversation

@manerow

@manerow manerow commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #37191

Problem

The buildEntityUrl template helper needs two arguments: the entity type and the entity. Two places still showed a one-argument example, {{buildEntityUrl entity}}:

  • the helpers API, GET /v1/notificationTemplates/helpers, which returns an example for each helper;
  • the help panel of the observability alert form, in the paragraph about helpers and in the sample body.

With one argument the helper has no entity type to build the path from, so it renders an empty string. Anyone who copies the example gets notifications with an empty link.

What this PR changes

  • The helpers API now returns {{buildEntityUrl event.entityType entity}} as the example. This is the same form the system templates and the published docs already use.
  • The alert form help uses the same two-argument form in both places.
  • A new unit test renders the example the API returns against a sample table event and checks that it produces the table's link. The test fails on the old example, which renders an empty link, and passes with the new one.

Cursor position for six helpers

The same API also tells the template editor where to put the cursor after it inserts a helper. For most helpers that position is right after the helper name, ready for the first argument. Six helpers were one character off: formatDate, math, length, textDiff, resolveDomain and renderTableSample. The cursor landed inside the closing braces.

The Collate template editor is starting to read its helper list from this API (collate#8309), so these positions now matter. This PR corrects the six and adds a test that checks the position for every helper the server registers. Before the fix, the test fails for exactly these six.

How it was tested

HandlebarsHelperMetadataTest, BuildEntityUrlHelperTest, NotificationTemplateHelperCoreTest, NotificationTemplateHelperAdvancedTest and SystemTemplateParityTest: 74 tests, all passing.

In the browser, on a local stack running this branch:

  • The alert form's hint panel for Notification Template shows {{buildEntityUrl event.entityType entity}} in both places.
  • With collate#8309's editor, inserting each of the six helpers and typing its arguments where the cursor lands gives the full call, such as {{formatDate event.timestamp}}.

Screenshots

The "before" column is the commit this PR is based on, with the Collate editor from collate#8309, because only that editor uses these values.

Before After
Alert form hint panel
Both examples showed the one-argument call, which renders an empty link. They now show the two-argument call.
1-before-hint-panel 1-after-hint-panel
Example in the {{ list
The example from the helpers API had the same one-argument call. It now shows the two-argument call.
2-before-example 2-after-example
formatDate picked, then its argument typed
The cursor landed inside the closing braces, so the argument ended up after a }. It now lands right after the helper name.
3-before-cursor 3-after-cursor

@manerow
manerow requested a review from a team as a code owner November 5, 2026 17:23
@manerow
manerow requested a review from sonika-shah November 5, 2026 17:23
@manerow manerow added UI UI specific issues backend labels Nov 5, 2026
@manerow manerow self-assigned this Nov 5, 2026
@github-actions github-actions Bot added the safe to test Add this label to run secure Github workflows on PRs label Nov 5, 2026
@gitar-bot

gitar-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Updating the buildEntityUrl example and helper cursor offsets affects notification links and editor insertion; incorrect metadata could leave copied templates broken.

Corrects the buildEntityUrl example returned by the helpers API and the alert form help to the two-argument form {{buildEntityUrl event.entityType entity}}, so copied templates produce a valid link. Also fixes cursor placement after insertion for six helpers and adds tests covering both. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@manerow
manerow merged commit 4f18963 into main Nov 6, 2026
73 checks passed
@manerow
manerow deleted the fix/37191-build-entity-url-example branch November 6, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notification templates: the one-argument buildEntityUrl example renders an empty link

2 participants