Skip to content

Conversation

NathanFlurry
Copy link
Member

No description provided.

Copy link
Member Author

NathanFlurry commented Jun 27, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

export const auth = betterAuth({
// IMPORTANT: Connect your own database here
database: sqliteAdapter(db),
// IMPORTANT: Connect a real database for productoin use cases
Copy link

Choose a reason for hiding this comment

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

There's a typo in the comment: productoin should be production

Suggested change
// IMPORTANT: Connect a real database for productoin use cases
// IMPORTANT: Connect a real database for production use cases

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

// user: [],
// account: [],
// session: [],
// verifcation: [],
Copy link

Choose a reason for hiding this comment

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

There's a typo in the property name: verifcation is missing an 'i' and should be verification

Suggested change
// verifcation: [],
// verification: [],

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

id: crypto.randomUUID(),
userId: c.auth.userId,
username: c.auth.user.email,
userId: "TODO",
Copy link

Choose a reason for hiding this comment

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

The userId field is currently hardcoded as "TODO", which will cause all messages to share the same user identifier. This should be replaced with the actual user ID from the authentication context, likely available at c.conn.auth.user.id. Using a static value here breaks user attribution in the chat system.

Suggested change
userId: "TODO",
userId: c.conn.auth.user.id,

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +145 to +152
if (proto !== null && proto !== Object.prototype) {
// Check if it's a known serializable object type
const constructor = value.constructor;
if (constructor && typeof constructor.name === "string") {
// Allow objects with named constructors (records, named objects)
// This includes user-defined classes and built-in objects
// that CBOR can serialize with tag 27 or record tags
}
Copy link

Choose a reason for hiding this comment

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

The validation logic for objects with non-standard prototypes appears incomplete. While the code checks for the presence of a named constructor, it doesn't perform any actual validation to determine if these objects are CBOR serializable. The empty if block with only comments suggests an unfinished implementation.

This could potentially allow non-serializable objects to pass validation, leading to runtime errors when serialization is attempted. Consider either:

  1. Implementing proper validation for these object types
  2. Explicitly rejecting objects with non-standard prototypes
  3. Documenting which specific object types with custom prototypes are supported
// Example of a more complete implementation:
if (constructor && typeof constructor.name === "string") {
  // Check if it's one of the known serializable types
  if ([KnownType1, KnownType2].includes(constructor)) {
    return true;
  }
  onInvalid?.(currentPath);
  return false;
}
Suggested change
if (proto !== null && proto !== Object.prototype) {
// Check if it's a known serializable object type
const constructor = value.constructor;
if (constructor && typeof constructor.name === "string") {
// Allow objects with named constructors (records, named objects)
// This includes user-defined classes and built-in objects
// that CBOR can serialize with tag 27 or record tags
}
if (proto !== null && proto !== Object.prototype) {
// Check if it's a known serializable object type
const constructor = value.constructor;
if (constructor && typeof constructor.name === "string") {
// Allow objects with named constructors (records, named objects)
// This includes user-defined classes and built-in objects
// that CBOR can serialize with tag 27 or record tags
const knownSerializableTypes = [
Date,
Map,
Set,
RegExp
// Add other known serializable types here
];
if (knownSerializableTypes.some(type => constructor === type)) {
return true;
}
onInvalid?.(currentPath);
return false;
}

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Copy link

graphite-app bot commented Jun 27, 2025

Merge activity

  • Jun 27, 8:54 AM UTC: NathanFlurry added this pull request to the Graphite merge queue.
  • Jun 27, 8:55 AM UTC: CI is running for this pull request on a draft pull request (#1030) due to your merge queue CI optimization settings.
  • Jun 27, 8:56 AM UTC: Merged by the Graphite merge queue via draft PR: #1030.

graphite-app bot pushed a commit that referenced this pull request Jun 27, 2025
@graphite-app graphite-app bot closed this Jun 27, 2025
@graphite-app graphite-app bot deleted the 06-27-chore_update_serializable_type_validation_to_check_for_wider_range_of_cbor_types_instead_of_json_types branch June 27, 2025 08:57
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.

1 participant