Fixes #: Activity feed creation API restrictions and UI JSON parsing crash#26679
Fixes #: Activity feed creation API restrictions and UI JSON parsing crash#26679
Conversation
Co-authored-by: aniketkatkar97 <51777795+aniketkatkar97@users.noreply.github.com> Agent-Logs-Url: https://github.com/open-metadata/OpenMetadata/sessions/5e663e5d-d6cb-45d3-8a84-971ab57b20bc
Code Review
|
| Auto-apply | Compact |
|
|
Was this helpful? React with 👍 / 👎 | Gitar
| if (TaskType.RequestTag.equals(taskType) || TaskType.UpdateTag.equals(taskType)) { | ||
| String suggestion = task.getSuggestion(); | ||
| String oldValue = task.getOldValue(); | ||
| if (suggestion != null && !JsonUtils.isValidJson(suggestion)) { | ||
| throw new IllegalArgumentException( | ||
| "taskDetails.suggestion must be a valid JSON for task type " + taskType); | ||
| } | ||
| if (oldValue != null && !JsonUtils.isValidJson(oldValue)) { | ||
| throw new IllegalArgumentException( | ||
| "taskDetails.oldValue must be a valid JSON for task type " + taskType); | ||
| } |
There was a problem hiding this comment.
⚠️ Bug: isValidJson allows non-array JSON, UI expects TagLabel[]
The new validateTaskDetails() calls JsonUtils.isValidJson() which accepts any valid JSON value — including plain strings ("hello"), numbers (42), booleans, and objects. However, the UI (TagsTask.tsx) and the backend task resolution (resolveTagTaskMessage → JsonUtils.readObjects) both expect these fields to be JSON arrays of TagLabel objects.
A payload like {"suggestion": "42"} or {"suggestion": ""hello""} would pass the new validation but still cause a deserialization error on task resolution or produce unexpected behavior in the UI (the try/catch would silently swallow the error and show an empty tag list).
Consider validating that the value is a JSON array specifically, e.g. by attempting to deserialize it as a list of TagLabel.
Suggested fix:
// Replace isValidJson with a stricter check:
if (suggestion != null) {
try {
JsonUtils.readObjects(suggestion, TagLabel.class);
} catch (Exception e) {
throw new IllegalArgumentException(
"taskDetails.suggestion must be a valid JSON array of tags for task type " + taskType);
}
}
// Same for oldValue
Was this helpful? React with 👍 / 👎 | Reply gitar fix to apply this suggestion
The feed API accepted and stored tasks with plain-string values in
suggestion/oldValuefields that must be JSON arrays (tag tasks), and allowedtaskDetailson non-Taskthread types. Stored corrupted payloads caused an unrecoverable full-page crash in the UI (Unexpected token 'h', "this is a d"... is not valid JSON).Backend (
FeedRepository.java)validateTaskDetails(): forRequestTag/UpdateTagtask types, rejectssuggestionoroldValuethat is not valid JSON (viaJsonUtils.isValidJson())createThread(): rejects any thread of typeConversation,Announcement, etc. that carries a non-nulltaskDetailsUI (
TagsTask.tsx)JSON.parse(oldValue),JSON.parse(newValue),JSON.parse(suggestion)calls into individualuseMemohooks withtry/catch, falling back to[]on parse failure — prevents the error boundary from catching a render-time exception on already-persisted bad dataType of change:
Checklist:
Fixes <issue-number>: <short explanation>Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
repository.apache.org/usr/lib/jvm/temurin-21-jdk-amd64/bin/java /usr/lib/jvm/temurin-21-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.13/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.13/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.13 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.13/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/OpenMetadata/OpenMetadata/openmetadata-service org.codehaus.plexus.classworlds.launcher.Launcher spotless:check -q(dns block)s3.amazonaws.com/usr/lib/jvm/temurin-21-jdk-amd64/bin/java /usr/lib/jvm/temurin-21-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.13/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.13/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.13 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.13/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/OpenMetadata/OpenMetadata/openmetadata-service org.codehaus.plexus.classworlds.launcher.Launcher spotless:check -q(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.