fix: changed topics/keywords to topic/keywords #13544
Merged
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.
Summary
The metadata with key "topic/keywords" is probably accepted and saved by the backend, but the UI won't show the value because it uses a map of metadata keys to show:
dify/web/hooks/use-metadata.ts
Line 68 in 1f38d48
'topics/keywords': { label: t(
${fieldPrefix}.webPage.topicsKeywords
) },Based on the file linked in the docs: https://github.com/langgenius/dify/blob/main/api/services/dataset_service.py#L475
The correct value should probably be "topic/keywords"
The backend seems to run validation on the accepted values for doc_type https://github.com/langgenius/dify/blob/main/api/controllers/service_api/dataset/document.py#L75
BUT it allows any Dictionary-Like object for the doc_metadata https://github.com/langgenius/dify/blob/main/api/controllers/service_api/dataset/document.py#L79
It should validate the object keys based on the values in dataset_service.py https://github.com/langgenius/dify/blob/main/api/services/dataset_service.py#L476
The UI hook should be updated to target the correct key "topic/keywords"
dify/web/hooks/use-metadata.ts
Line 68 in 1f38d48
'topics/keywords': { label: t(
${fieldPrefix}.webPage.topicsKeywords
) },Along with the translation key
dify/web/i18n/en-US/dataset-documents.ts
Line 136 in 1f38d48
topicsKeywords: 'Topics/Keywords',
So I updated these files and the corresponding translations to use topic/Keywords or topicKeywords
Fixes #13502
Screenshots
Checklist
Important
Please review the checklist below before submitting your pull request.
dev/reformat
(backend) andcd web && npx lint-staged
(frontend) to appease the lint gods