Skip to content

fix: knowledge document strategy permission - #7745

Merged
peslyn merged 1 commit into
v3from
pr@v3@fix_knowledge_document_strategy_permission
Nov 9, 2026
Merged

peslyn merged 1 commit into
v3from
pr@v3@fix_knowledge_document_strategy_permission

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: knowledge document strategy permission

<el-button v-if="knowledgeExternalServicePermission('knowledgeExternalServiceEdit')" type="primary" class="mt-4" :loading="saving" @click="handleSave">保存</el-button>
<el-button v-if="knowledgeDocumentStrategyPermission('documentStrategyEdit')" type="primary" class="mt-4" :loading="saving" @click="handleSave">保存</el-button>
</div>
</template>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff is syntactically consistent, but there are a few review points:

  1. Likely permission bug for workspace-shared resources

    if (isWorkspaceSharedResource()) return false // 共享知识库在工作空间侧只读

    This returns false for both documentStrategyRead and documentStrategyEdit. If the function is ever called with documentStrategyRead, read access is denied, which contradicts the “read-only” comment.
    Suggested fix if read should be allowed:

    if (isWorkspaceSharedResource()) {
      return method === 'documentStrategyRead'
    }

    Or, if only edit is ever used, narrow the type/function to edit-only to avoid misleading semantics.

  2. Permission key rename is a breaking change
    The permission methods changed from:

    • knowledgeExternalServiceRead → documentStrategyRead
    • knowledgeExternalServiceEdit → documentStrategyEdit

    Ensure perm.knowledge.system and perm.knowledge.share actually expose these new method names. Otherwise:

    perm.knowledge.system[method]()

    can throw if [method] is undefined. Also check backend permission codes, role configuration, tests, audit logs, and any persisted permissions for migration/backward compatibility.

  3. Runtime safety for permission lookup
    Consider guarding the dynamic call:

    return Boolean(perm.knowledge?.system?.[method]?.())

    and similarly for perm.knowledge.share. This avoids crashes if permissions are not loaded yet or a key is missing.

  4. Duplicate permission check
    handleSave checks edit permission, and the button also checks it via v-if. This is acceptable, but a computed property would avoid duplication:

    const canEditDocumentStrategy = computed(() =>
      knowledgeDocumentStrategyPermission('documentStrategyEdit')
    )

    Then use it in both places.

  5. Minor existing issue
    max-w-200 is not a standard Tailwind utility unless custom-configured. Verify it resolves correctly.

Overall, the rename itself looks internally consistent in the shown diff. The main risks are the workspace-shared read behavior and ensuring the new permission identifiers exist everywhere.

@peslyn
peslyn merged commit df666ae into v3 Nov 9, 2026
3 of 4 checks passed
@peslyn
peslyn deleted the pr@v3@fix_knowledge_document_strategy_permission branch November 9, 2026 06:26
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.

2 participants