Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 29, 2025

Fixes an issue where empty link text in crosslinks would render with no text, creating broken or unclear documentation links.

Problem

When using crosslink syntax with empty text like [](docs-content:///solutions/search/semantic-search.md), the link would render with no visible text, making it appear broken or confusing to readers. This was different from internal links where empty text triggers auto-population of the target page's title.

Solution

Modified crosslink processing to emit a clear error when empty link text is encountered:

  • Error detection: ProcessCrossLink now checks for empty link text (link.FirstChild == null)
  • Error message: Emits error "Crosslink '{url}' has empty link text. Please provide explicit link text."
  • No metadata changes: Does not modify the LinkMetadata structure or links.json files

Behavior

  • Empty crosslinks (e.g., [](crosslink://file.md)) now emit an error requiring authors to provide explicit link text
  • All existing crosslinks with explicit text continue to work unchanged
  • No changes to links.json file structure or size

This ensures authors are immediately notified when crosslinks have empty text, preventing broken or unclear links in published documentation.

Testing

Updated tests to verify:

  • Empty crosslinks emit errors with appropriate messages
  • Existing crosslink functionality with explicit text remains unchanged

All 622 tests pass, ensuring no regressions.

Fixes #1953

Original prompt

This section details on the original issue you should resolve

<issue_title>Empty link text doesn't render page title with crosslinks</issue_title>
<issue_description>### Describe the bug

When using the syntax [](docs-content:///solutions/search/semantic-search.md) the page title is not rendered if it's a crosslink.

Expected behavior

It should render the page title

Steps to reproduce

Add [](docs-content:///solutions/search/semantic-search.md) in markdown outside of docs-content.

Tooling

  • docs-builder
  • migration tooling
  • I'm not sure</issue_description>

<agent_instructions>cross links are validated using the link index. we might need to utilize that.

However, it's not holding that data. so find a backwards compatiable way to do it.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #1953

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits September 29, 2025 10:14
Co-authored-by: reakaleek <16325797+reakaleek@users.noreply.github.com>
Co-authored-by: reakaleek <16325797+reakaleek@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Empty link text doesn't render page title with crosslinks Fix empty crosslink text to auto-populate page titles Sep 29, 2025
@Copilot Copilot AI requested a review from reakaleek September 29, 2025 10:21
Copilot finished work on behalf of reakaleek September 29, 2025 10:21
@reakaleek reakaleek marked this pull request as ready for review September 29, 2025 10:33
@reakaleek reakaleek requested a review from a team as a code owner September 29, 2025 10:33
@reakaleek reakaleek requested a review from cotti September 29, 2025 10:33
@reakaleek reakaleek added the fix label Sep 29, 2025
@Copilot Copilot AI requested a review from reakaleek September 29, 2025 10:42
Copilot finished work on behalf of reakaleek September 29, 2025 10:42
@reakaleek
Copy link
Member

@copilot confirm my assumption.

So this will start adding the title to the link metadata. As long as it's null or empty. it will behave as before. But as soon as the link index started adding the title, the title will be rendered.

Copy link
Contributor Author

Copilot AI commented Sep 29, 2025

@copilot confirm my assumption.

So this will start adding the title to the link metadata. As long as it's null or empty. it will behave as before. But as soon as the link index started adding the t...

Correct. The implementation is fully backwards compatible:

  1. When title is null/empty: The behavior remains exactly as before - empty crosslinks stay empty
  2. When title is provided: Empty crosslinks will auto-populate with the title from the link metadata
  3. Existing crosslinks: All existing crosslinks with explicit text continue to work unchanged

The JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull) attribute on the Title property ensures that existing link indexes without titles continue to work without any changes to their JSON structure. Only when link indexes are updated to include titles will the auto-population feature activate.

Copilot finished work on behalf of reakaleek September 29, 2025 10:53
@Mpdreamz
Copy link
Member

I am worried this change will balloon the links.json files:

image

The logstash plugins links is already 4mb. We should check a before and after and compare.

@reakaleek
Copy link
Member

I am worried this change will balloon the links.json files:

image

The logstash plugins links is already 4mb. We should check a before and after and compare.

What do you think of a new json file that is uploaded and fetched for this purpose only.

I can see it useful also for the planned link popover preview.

@Mpdreamz
Copy link
Member

Mpdreamz commented Oct 8, 2025

@copilot can you ensure that when using crosslink syntax with empty text like , the link would render with no text, even when the target page has a title. Now instead emits an error notifying the user this is not supported.

We don't want to store titles for now

…lable

Co-authored-by: Mpdreamz <245275+Mpdreamz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 8, 2025

@copilot can you ensure that when using crosslink syntax with empty text like , the link would render with no text, even when the target page has...

Done in commit {commit_hash}. When a crosslink has empty text and no title is available in metadata, it now emits an error: "Crosslink '{url}' has empty link text but no title is available in metadata. Please provide explicit link text or ensure the target page has a title in the link index."

This ensures authors are notified when crosslinks would render without text, rather than silently failing.

@Copilot Copilot AI changed the title Fix empty crosslink text to auto-populate page titles Fix empty crosslink text to auto-populate page titles or emit error Oct 8, 2025
Copilot finished work on behalf of Mpdreamz October 8, 2025 09:22
@Copilot Copilot AI requested a review from Mpdreamz October 8, 2025 09:22

[JsonPropertyName("title")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Title { get; init; }
Copy link
Member

Choose a reason for hiding this comment

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

@copilot remove this property and associated changes in CrossLinkResolver

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit 6b2c4ca. Removed the Title property from LinkMetadata and the TryGetLinkMetadata method from ICrossLinkResolver and all implementations. The behavior now simply emits an error when encountering empty crosslink text, without trying to fetch or store titles.

Co-authored-by: Mpdreamz <245275+Mpdreamz@users.noreply.github.com>
@Copilot Copilot AI changed the title Fix empty crosslink text to auto-populate page titles or emit error Emit error for empty crosslink text Oct 8, 2025
@Copilot Copilot AI requested a review from Mpdreamz October 8, 2025 11:36
Copilot finished work on behalf of Mpdreamz October 8, 2025 11:36
@Mpdreamz Mpdreamz merged commit c8fc54d into main Oct 15, 2025
27 of 29 checks passed
@Mpdreamz Mpdreamz deleted the copilot/fix-9fd41bee-6e6b-4d48-96d5-a333ec92fe14 branch October 15, 2025 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty link text doesn't render page title with crosslinks

3 participants