-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Unable to select group viewing permissions #9541
fix: Unable to select group viewing permissions #9541
Conversation
…al null in page route
|
@@ -530,7 +530,7 @@ module.exports = (crowi) => { | |||
} = page; | |||
let isGrantNormalized = false; | |||
try { | |||
const grantedUsersId = grantedUsers.map(ref => getIdForRef(ref)); | |||
const grantedUsersId = grantedUsers?.map(ref => getIdForRef(ref)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
バグの原因は page.grantedUsers が null の時に null 許容の実装になっていないことから 500 エラーが返却されることが原因だった。
@growi/app:dev: 02:28:35.201Z ERROR growi:routes:apiv3:page:
@growi/app:dev: Error occurred while processing isGrantNormalized. TypeError: Cannot read properties of null (reading 'map')
@growi/app:dev: at /workspace/growi/apps/app/src/server/routes/apiv3/page/index.ts:533:43
@growi/app:dev: at processTicksAndRejections (node:internal/process/task_queues:95:5)
@growi/app:dev: GET /_api/v3/page/grant-data?pageId=62a1a77c6efd10033d9504cb 500 7.355 ms - 85
packages/core/src/interfaces/page.ts
Outdated
@@ -28,7 +28,7 @@ export type IPage = { | |||
descendantCount: number, | |||
isEmpty: boolean, | |||
grant: PageGrant, | |||
grantedUsers: Ref<IUser>[], | |||
grantedUsers?: Ref<IUser>[], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null 許容型に変更
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type IPage の改修による変更
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type IPage の改修による変更
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type IPage の改修による変更
const requests = [ | ||
{ | ||
updateMany: { | ||
filter: { grantedUsers: null }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filter: {
$or: [
{ grantedGroups: null },
{ grantedGroups: { $exists: false } }
]
}
にしないと、フィールドが存在しない場合は filter に引っかからないんじゃないかな
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
item: null
は null or 存在しないフィールドにマッチするようです。(手元で動作確認もしました)
The { item : null } query matches documents that either contain the item field whose value is null or that do not contain the item field.
https://www.mongodb.com/docs/manual/tutorial/query-for-null-fields/#equality-filter
@mergify queue |
✅ The pull request has been merged automaticallyThe pull request has been merged automatically at cc7a2bc |
Task