[codex] Guard metadata sorting against non-string labels#36
Closed
[codex] Guard metadata sorting against non-string labels#36
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideMakes 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 normalizationclassDiagram
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
Flow diagram for normalized label computation used in sortingflowchart 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]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
a9f6c54 to
bf9dc23
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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:
Enhancements: