Sanitizing misidentifies diamond-shaped references as cycles
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 57/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- typescript
- 領域
- database
調査の方向性
issue にあるダイヤモンド形の create ケースを再現し、その後 #sanitizeInitialValues 内の内部 sanitize メソッドを調べます。両方の兄弟パスを通じて共有レコードをサニタイズした場合に、author.profile と editor.profile の両方が定義されたままになることを確認します。
索引モデルが issue の本文から書いたものです。
説明
This is a very similar issue to #348, but occurs when the same record is referenced from two different paths in a create call.
For example, this code results in the same type of validation error as #348:
import { Collection } from '@msw/data';
import * as v from 'valibot';
const profileSchema = v.object({
id: v.string(),
bio: v.string(),
});
const userSchema = v.object({
id: v.string(),
name: v.string(),
get profile() { return profileSchema; },
});
const postSchema = v.object({
id: v.string(),
title: v.string(),
get author() { return userSchema; },
get editor() { return userSchema; },
});
const profiles = new Collection({ schema: profileSchema });
const users = new Collection({ schema: userSchema });
const posts = new Collection({ schema: postSchema });
users.defineRelations({ one }) => ({ profile: one(profiles) }));
posts.defineRelations({ one }) => ({
author: one(users),
editor: one(users),
}));
const profile = await profiles.create({ id: 'p1', bio: 'hi' });
const user = await users.create({ id: 'u1', name: 'Alice', profile });
// Diamond: same user referenced from two sibling fields
await posts.create({
id: 'post1',
title: 'Hello',
author: user,
editor: user,
});
In this setup, either author.profile or editor.profile will be undefined after sanitization.
From my testing, I've been able to fix the error by adding the following to the inner sanitize method within the #sanitizeInitialValues method:
const result = Object.fromEntries(...);
if (record && !isRevisit) {
visited.delete(record[kPrimaryKey]);
}
return result;
- 主要言語
- TypeScript
- スター
- 1.1k
- フォーク
- 66
- 平均マージ
- 3分
- マージ済み PR(30日)
- 2
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
mswjs/data のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
-
potentially resolved
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
-
Non-nullable self-referencing relations対応中かも @kettanaito が 372 日前に担当しました。 オープン
似ている issue
-
status: needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
a2ui-project/a2ui#3158 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
hemilabs/ui-monorepo#2475 ·
メンテナーはふだん 1 日以内に返信
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
lingdojo/kana-dojo#32279 · コメント 1 件 · リアクション 5 件 ·
メンテナーはふだん 1 日以内に返信
-
code-quality refactoring
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
github/gh-aw-firewall#9879 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: Arrow-key cursor movement in combined diff view doesn't scroll to keep the cursor visibleオープンos:macos
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信