Repository navigation
delete: knowledge export skills - #7722
Conversation
| //RESOURCE_KNOWLEDGE_EXPORT_SKILLS: p(Group.SYSTEM_RES_KNOWLEDGE, Group.SYSTEM_RES_KNOWLEDGE, Operate.EXPORT_SKILLS, 45), | ||
| RESOURCE_KNOWLEDGE_IMAGE_READ: p(Group.SYSTEM_RES_KNOWLEDGE, Group.SYSTEM_IMAGE, Operate.READ, 46), | ||
| RESOURCE_KNOWLEDGE_IMAGE_CREATE: p(Group.SYSTEM_RES_KNOWLEDGE, Group.SYSTEM_IMAGE, Operate.CREATE, 47), | ||
| RESOURCE_KNOWLEDGE_IMAGE_EDIT: p(Group.SYSTEM_RES_KNOWLEDGE, Group.SYSTEM_IMAGE, Operate.EDIT, 48), |
There was a problem hiding this comment.
Based on the diff only, there are no syntax errors, but there are several risks and inconsistencies:
-
Commented-out code is a maintenance smell
//KNOWLEDGE_EXPORT_SKILLS...,//SHARED_KNOWLEDGE_EXPORT_SKILLS..., and//RESOURCE_KNOWLEDGE_EXPORT_SKILLS...leave dead code.- Prefer either:
- Permanent removal + all dependent cleanup, or
- Feature flag / deprecation marker if temporary.
- Also,
//KNOWLEDGE...lacks a space after//; some lint rules flag commented-out code.
-
Inconsistent removal strategy
APPLICATION_CLEAR_POLICYis deleted, while the three export-skills permissions are commented out.- Decide whether these permissions are temporarily disabled or permanently removed, and apply one consistent approach.
-
High risk of dangling references
- Search the entire repo for:
KNOWLEDGE_EXPORT_SKILLSSHARED_KNOWLEDGE_EXPORT_SKILLSRESOURCE_KNOWLEDGE_EXPORT_SKILLSAPPLICATION_CLEAR_POLICYEXPORT_SKILLSCLEAR_POLICY
- TypeScript will catch direct property access such as
PermissionConstants.KNOWLEDGE_EXPORT_SKILLS, but will not catch string-based/dynamic references, API payloads, role definitions, tests, or frontend permission keys. - Check whether
Operate.EXPORT_SKILLSorOperate.CLEAR_POLICYbecome unused enum members.
- Search the entire repo for:
-
Persisted permissions are not disabled by this diff
- If permissions are stored in a database, commenting/removing constants does not remove existing permission records or role mappings.
- You likely need a migration/data cleanup to:
- delete or deactivate the removed permissions,
- remove role/permission associations,
- invalidate permission caches.
- Otherwise the backend may still honor existing stored permissions.
-
Check for fail-open authorization behavior
- Verify how authorization behaves when a permission key is missing or unknown.
- If lookup returns
undefinedand the caller treats that as “allowed” or “no restriction,” export-skill access may remain possible. Ensure missing permission means deny.
-
Numeric permission codes should not be reused
- Codes
13,42,45, and64are now absent or commented out. - If these codes are persisted or exposed externally, do not reassign them to new permissions later.
- Consider reserving them explicitly, e.g. a comment or a
RESERVED_PERMISSION_CODESentry, to prevent accidental reuse. - Also verify that gaps in numeric codes do not break ordering, generated manifests, bitmasks, or external integrations.
- Codes
-
Generated artifacts and permission consumers may need updates
- Check for anything that iterates over
Object.keys(PermissionConstants)orObject.values(PermissionConstants). - Update tests, snapshots, docs, i18n labels, OpenAPI/API permission manifests, frontend permission lists, and seeded role definitions.
- Check for anything that iterates over
-
Recommended approach
- If temporary: keep the constants but mark them
@deprecated, and gate authorization with a server-side feature flag. Add a ticket/reason comment. - If permanent: delete the constants and unused
Operatevalues, remove all references, add a DB migration, and update tests/docs. Do not leave commented-out entries in committed code.
- If temporary: keep the constants but mark them
In short: the diff is syntactically fine, but it needs a repo-wide reference audit, a database/permission migration plan, consistent handling of removed permissions, and confirmation that missing permissions fail closed.
| exportSkills: () => canSys(P.RESOURCE_KNOWLEDGE_EXPORT_SKILLS), | ||
| /** | ||
| * 系统「知识库」「定时同步」只读权限 | ||
| */ |
There was a problem hiding this comment.
Review of the diff
What the diff does: removes the exportSkills permission helper (and its JSDoc) from the system permission object.
Potential issues
-
Dangling references → runtime crash. Grep the whole repo for
exportSkillsandRESOURCE_KNOWLEDGE_EXPORT_SKILLSbefore merging. Any remainingsystem.exportSkills()call will throwTypeError: system.exportSkills is not a function, and any leftover import of the constant will fail to resolve. -
Security / privilege regression. This is a permission gate. If the export feature still exists, deleting the check may leave it unguarded (or guarded only by a broader permission like
RESOURCE_KNOWLEDGE_MCP_CONFIG), effectively granting export to users who shouldn't have it. Confirm the export route still has an authorization check, or that the feature itself was removed. -
Persisted permission keys. If permission codes are stored in the DB (roles, tenant configs, audit logs), removing the mapping can:
- leave orphan rows / stale grants,
- produce "unknown permission" validation errors on save,
- silently drop grants on the next write.
Consider a migration, or keep the key resolvable (deprecated) for one release.
-
UI / API contract. Frontend or downstream consumers may read a permission list (e.g.
GET /permissions) to show/hide the export button. Removing the entry changes that contract — check snapshots, OpenAPI/type definitions, i18n labels, and docs. -
Dead constant. If
P.RESOURCE_KNOWLEDGE_EXPORT_SKILLSis now unreferenced, remove it too (and its backend definition/enum entry); otherwise you keep dead code that suggests the permission still exists. -
Tests. Update/remove unit tests, permission-table snapshots, and any fixtures asserting the full permission set.
Style / minor
-
Formatting artifact. The pasted hunk shows inconsistent leading whitespace (the removed
/**block is indented differently frommcpConfig). Verify the real file uses the same 2‑space indentation and aligned JSDoc as its neighbours — the paste may just be mangled, but it's worth a glance. -
Naming consistency. Other entries are named after the resource (
mcpConfig);exportSkillsmixes an action with the resource. If this permission is being renamed rather than deleted, preferknowledgeExportSkillsand keep the old name as an alias for a deprecation cycle.
Recommendation
If the export capability is gone: delete the constant + all call sites + tests in the same commit.
If it's only being renamed/consolidated: export a deprecated alias and migrate callers first, then remove in a follow-up. In both cases, run tsc --noEmit / lint with unused-export detection, and add a note to the changelog since this is an authorization-surface change.
| exportSkills: (id: string) => canWorkspaceKnowledge(P.KNOWLEDGE_EXPORT_SKILLS, id), | ||
| /** | ||
| * 工作空间「知识库」「定时同步」只读权限 | ||
| */ |
There was a problem hiding this comment.
Based on the provided diff, the change simply removes the exportSkills permission helper:
/**
* 工作空间「知识库」导出权限
*/
exportSkills: (id: string) => canWorkspaceKnowledge(P.KNOWLEDGE_EXPORT_SKILLS, id),Here are the issues and suggestions to verify:
-
Check for remaining references
- Search for
workspace.exportSkills/exportSkillsandP.KNOWLEDGE_EXPORT_SKILLS. - If any callers remain, this is a TypeScript compile error or a runtime
undefinedcall. All usages must be removed or migrated.
- Search for
-
Check whether
P.KNOWLEDGE_EXPORT_SKILLSis now dead code- If no longer used anywhere, remove the constant to avoid dead permissions.
- If the backend permission still exists and may be used later, consider deprecating it rather than silently leaving an unused constant.
-
Backend authorization must still be enforced
- Frontend permission helpers are only for UX. Confirm the export API/endpoint independently verifies authorization. Do not rely on removing the frontend check as a security control.
-
Check related UI and routing
- Confirm the export button/menu/action and any related route or feature flag are also removed or hidden.
- Otherwise users may still trigger export through another path.
-
Verify tests, docs, and i18n
- Remove/update tests referencing
exportSkills. - Update permission documentation, API contracts, and translation keys if the export feature is fully removed.
- Remove/update tests referencing
-
Consider backward compatibility
- If this module is consumed by other packages/apps, removing an exported member is a breaking change. Use a deprecated alias or a major version bump if needed.
-
Formatting/comment consistency
- The deletion itself leaves the surrounding object and comments syntactically valid:
mcpConfigkeeps its trailing comma, and the next JSDoc block follows correctly. - No semicolon/style issue is introduced by this hunk.
- The deletion itself leaves the surrounding object and comments syntactically valid:
-
Optimization
- If several permission helpers follow the same pattern, consider generating them from a permission map to reduce repetition, but only if it improves readability and type safety.
Overall: the diff is syntactically clean, but the main risk is dangling references or an inconsistent removal of the export feature/permission. Search the entire repository for exportSkills and KNOWLEDGE_EXPORT_SKILLS before merging.
delete: knowledge export skills