fix(knowledge): allow xlsx in URL import (#2447) - #2452
Merged
Conversation
…t#2447) Align URL-based file import validation with direct file upload by delegating to isValidFileType instead of a narrower whitelist.
Remove .cursor hooks from the repo and drop gitignore exceptions so local Cursor rules and hooks stay out of version control.
Extract shared file-import checks (type, VLM/ASR, video) into resolveKnowledgeFileImportConfig and reuse them for file URL import. Also enqueue DataTableSummaryTask for spreadsheet URL imports and reparse.
…le gate The xlsx URL-import fix left the accepted extension set reachable through two indirections and widened ApplyKnowledgeProcessOverrides to gate file types for callers that are not file imports (web URL fetch, connector sync, reparse). Collapse the set into one map that both isValidFileType and the extension check read, move the shared validation next to the other file-type predicates, and return ApplyKnowledgeProcessOverrides to its override-only scope so resolveFileImportProcessConfig is the only import gate. Also drop the unreachable branch in createKnowledgeFromFileURL: getFileType never yields an empty string, so the resolvedFileType fallback and its else arm could not run. Normalize the resolved type before it reaches the record and the task payload, and add an invariant test asserting direct upload and URL import accept the same extensions so Tencent#2447 cannot drift back.
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.
Summary
#2447: URL-based knowledge import (POST /knowledge-bases/:id/knowledge/url) now accepts the same file types as direct upload (includingxlsx,xls,csv) by reusingisValidFileTypeinstead of a narrower whitelist.resolveKnowledgeFileImportConfigenforces file type, video rejection, and default VLM/ASR prerequisites.DataTableSummaryTaskfor spreadsheet URL imports (create + reparse), matching direct upload behavior..cursorIDE config (hooks/rules) in git.Test plan
go test ./internal/application/service/ -count=1go test ./internal/application/service/ -run 'TestIsAllowedFileURLExtension|TestIsValidFileTypeHTML|TestValidateImportFileType|TestResolveKnowledgeFileImportConfig|TestApplyKnowledgeProcessOverrides'/api/v1/knowledge-bases/:id/knowledge/urlwith{"url": "...", "file_name": "test.xlsx", "file_type": "xlsx"}returnssuccess: trueexe) still return 400