Skip to content

fix(resource): exclude inline payloads from fallback searches - #269

Merged
hustcc merged 1 commit into
antvis:mainfrom
cangen185-sudo:codex/fix-inline-resource-fallback
Dec 1, 2026
Merged

hustcc merged 1 commit into
antvis:mainfrom
cangen185-sudo:codex/fix-inline-resource-fallback

Conversation

@cangen185-sudo

Copy link
Copy Markdown
Contributor

Failed inline SVG/image resources currently use their raw payload as an icon-search query. getFallbackQuery() returns cfg.data before reaching its existing inline/data-URI/SVG exclusions, so an item label, description, or the default icon/illustration query is never selected for nonempty inline data.

Apply those exclusions before accepting the configured query. Preserve the current priority of searchable configuration text, including bare icon names such as plane; only fall back to the item context and scene default when the configured data is excluded or empty. Successful primary loading is unchanged.

Validation on main 5ae0d9394ac6280cb688eb4b4345881e291b9209:

  • Added 11 regression cases through loadResource; the original code fails 8 and passes 3, while the patch passes all 11.
  • Resource and SSR tests: 51 passed, including all existing SSR SVG snapshots without updates.
  • npm run build:esm, npm run check:test, and ESLint/Prettier on the two changed files passed.
  • A separate smoke check used the built ESM package, real resource parser/loaders and a mocked HTTP response, confirming the fallback query and installed SVG symbol without external network access.

This PR was prepared with AI assistance. Local validation used Windows and Node.js 24; the repository's macOS/Node.js 20 CI remains the remote validation boundary.

@hustcc

hustcc commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

@cangen185-sudo Help to give a bad case show the before and after.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the fallback-search changes.

No open issues 🎉

What changed in this PR

Fixes resource fallback searches so failed inline SVG and image payloads are not used as search queries. Searchable configuration text retains priority; excluded or empty data falls back to the item context or scene default.

Changes:

  • Applies inline, data-URI, and SVG exclusions before accepting configured search text.
  • Adds 11 regression cases covering fallback selection, query priority, and unchanged successful primary loading.
File Description
src/​resource/​loader.ts Reorders fallback query selection to exclude payloads before using item context or defaults.
__tests__/​unit/​resource/​loader.test.ts Adds regression coverage for fallback queries and successful primary loading.

Review effort: Balanced

@cangen185-sudo

Copy link
Copy Markdown
Contributor Author

@hustcc Here’s a concrete before/after. The item is labelled Computer network, but its inline SVG is truncated and cannot load:

await loadResource(
  svg,
  'icon',
  { source: 'inline', format: 'svg', encoding: 'raw', data: '<svg broken' },
  { label: 'Computer network' },
);

I ran the fallback-query function from base 5ae0d93 and PR head 9680c46 against the same inputs:

Input Search term before Search term after
Broken SVG, label “Computer network” <svg broken Computer network
Same broken SVG, no label or description <svg broken icon
Explicit search for plane, label “Computer network” plane plane

Previously the search provider received the markup itself. With the patch it can look up the subject of the item. The exact artwork depends on the provider. The regression test checks the query through loadResource and verifies that the returned symbol is installed in the SVG.

@hustcc
hustcc merged commit 7b25b67 into antvis:main Dec 1, 2026
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.

3 participants