Skip to content

[codex] Guard metadata sorting against non-string labels#36

Closed
hcvdwerf wants to merge 0 commit intomainfrom
codex/fix-metadata-sort-crash
Closed

[codex] Guard metadata sorting against non-string labels#36
hcvdwerf wants to merge 0 commit intomainfrom
codex/fix-metadata-sort-crash

Conversation

@hcvdwerf
Copy link
Copy Markdown

@hcvdwerf hcvdwerf commented Apr 20, 2026

What changed

This change makes metadata and SHACL sorting null-safe by coercing labels and paths to strings before calling string comparison methods.

Why it changed

The deployed v1.0.4 frontend can show Unable to get data. even when the underlying API requests succeed. The likely cause is a client-side exception introduced by the new alphabetical metadata sorting logic between v1.0.3 and v1.0.4.

Root cause

The sorting code called toLocaleLowerCase() on values that can be null, undefined, or otherwise non-string depending on the SHACL and data payload returned by the environment.

Impact

This prevents the entity view from failing during metadata processing when labels are missing or not plain strings.

Validation

  • npm run lint
  • npm run build
  • earlier install/lint/build smoke checks on the dependency PR branches

Summary by Sourcery

Make metadata and SHACL field/group sorting robust to missing or non-string labels to avoid client-side failures during entity rendering.

Bug Fixes:

  • Prevent runtime errors in metadata sorting when SHACL labels, IRIs, names, or paths are null, undefined, or non-string values.

Enhancements:

  • Normalize label values through a shared string-coercion helper in the entity view before performing locale-aware comparison.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 20, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Makes SHACL metadata and entity view sorting null-safe by normalizing potentially non-string labels/paths to strings before performing locale-aware, case-insensitive comparisons, preventing runtime errors when labels are missing or non-strings.

Class diagram for updated SHACL sorting and EntityView label normalization

classDiagram
  class Group_F_ {
    +any label
    +any iri
    +number order
    +compare(other Group_F_) number
  }

  class Field_S_ {
    +any name
    +any path
    +number order
    +compare(other Field_S_) number
  }

  class EntityView {
    +normalizedSortLabel(value unknown) string
    +actionEnabled(action string) boolean
  }

  Group_F_ : compare(other Group_F_) number
  Group_F_ : label = String(this.label ?? this.iri ?? "").toLocaleLowerCase()
  Group_F_ : otherLabel = String(other.label ?? other.iri ?? "").toLocaleLowerCase()

  Field_S_ : compare(other Field_S_) number
  Field_S_ : label = String(this.name ?? this.path ?? "").toLocaleLowerCase()
  Field_S_ : otherLabel = String(other.name ?? other.path ?? "").toLocaleLowerCase()

  EntityView : normalizedSortLabel(value unknown) string
  EntityView : returns String(value ?? "").toLocaleLowerCase()

  EntityView --> Field_S_ : sorts by fields_0_label via normalizedSortLabel
Loading

Flow diagram for normalized label computation used in sorting

flowchart TD
  A[Input value for sorting] --> B{Is value null or undefined?}
  B -- Yes --> C[Use empty string]
  B -- No --> D[Use original value]
  C --> E[Coerce to string using String]
  D --> E[Coerce to string using String]
  E --> F[Call toLocaleLowerCase]
  F --> G[Return normalized lowercase string for locale-aware compare]
Loading

File-Level Changes

Change Details Files
Harden SHACL group and field comparison logic against non-string labels and IRIs.
  • Replace chained `
Centralize and reuse normalized label handling in EntityView metadata sorting.
  • Introduce a normalizedSortLabel(value: unknown): string helper that null-coalesces and stringifies input before lowercasing.
  • Update the metadata sorting _.orderBy iteratee to use the new helper instead of calling .toLocaleLowerCase() directly on a possibly undefined label path.
src/components/EntityView/index.vue

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@hcvdwerf hcvdwerf closed this Apr 20, 2026
@hcvdwerf hcvdwerf force-pushed the codex/fix-metadata-sort-crash branch from a9f6c54 to bf9dc23 Compare April 20, 2026 18:55
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.

1 participant