chore: update record id type to number in response schema#205
chore: update record id type to number in response schema#205stephansama wants to merge 7 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: d5704e3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Summary of ChangesHello @stephansama, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a type inconsistency in the API response schema. It updates the expected type for record IDs from string to number, aligning the schema definition with the actual data type and improving type safety for API consumers. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughAdded a generic Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Code Review
This pull request updates the id type in the CREATE action's response schema from a string to a number, which improves consistency with other actions like LIST and READ. While this is a good change, it's incomplete as it doesn't update the corresponding unit test, which will cause it to fail. I've also noted an inconsistency in the UPDATE action which still expects a string id, and I recommend addressing that for better API consistency.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
core/typed-nocodb-api/src/index.ts (1)
75-79:⚠️ Potential issue | 🟠 MajorUPDATE
inputSchemastill typesidasz.string()— inconsistent with the rest.Every other operation now uses
z.number()for record IDs (CREATE response on line 40, LIST on line 66, READ on line 72, DELETE on line 45). The UPDATEinputSchemaon line 76 still usesz.string(), which looks like an oversight. If NocoDB record IDs are numbers, this should be updated too.Note: the UPDATE test also uses
id: "123"(string), so it would need updating as well.Proposed fix
UPDATE: { - inputSchema: z.object({ fields: schema, id: z.string() }), + inputSchema: z.object({ fields: schema, id: z.number() }), method: "patch",And in the test file:
const updateData = { fields: { completed: true, title: "Updated" }, - id: "123", + id: 123, };
🤖 Fix all issues with AI agents
In `@core/typed-nocodb-api/src/index.ts`:
- Around line 39-41: The responseSchema currently requires id: z.number(), but
tests mock CREATE responses with id as a string ("123"); update the schema
declaration (the responseSchema object that builds records: z.array(z.object({
fields: schema, id: z.number() }))) to accept both string and number (e.g., use
a union or a preprocess coercion to number) so Zod parsing succeeds for the test
mock; alternatively, if you prefer stricter typing, change the test mock in
core/typed-nocodb-api/test/index.test.ts to use a numeric id instead of "123".
More templates
@stephansama/ai-commit-msg
@stephansama/alfred-kaomoji
@stephansama/astro-iconify-svgmap
@stephansama/auto-readme
@stephansama/catppuccin-opml
@stephansama/catppuccin-rss
@stephansama/catppuccin-typedoc
@stephansama/catppuccin-xsl
create-stephansama-example
@stephansama/find-makefile-targets
@stephansama/github-env
@stephansama/multipublish
@stephansama/prettier-plugin-handlebars
@stephansama/remark-asciinema
@stephansama/svelte-social-share-links
@stephansama/typed-events
@stephansama/typed-nocodb-api
@stephansama/typed-templates
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
core/typed-nocodb-api/test/index.test.ts (1)
17-23: 🛠️ Refactor suggestion | 🟠 MajorNo test coverage for the new
referencesparameter.The
referencesfeature is the main addition in this PR, but no test exercisescreateApiwith areferencesarray. Given the inverted-condition bug flagged in the source file, a test would have caught it immediately. Consider adding at least one test that passesreferences: ["SomeLink"]and validates that the response schema correctly parses records containing reference fields.core/typed-nocodb-api/src/index.ts (1)
90-93:⚠️ Potential issue | 🟡 MinorREAD response schema should include
referenceSchemaintersectionREAD is the only record-returning action using
fields: schemawithoutreferenceSchema. CREATE, LIST, and UPDATE all composefields: schema.and(referenceSchema)(lines 52, 83, 101). If READ responses can contain reference fields from the API, they will fail validation at parse time. Update line 92 to match the pattern:fields: schema.and(referenceSchema).
🤖 Fix all issues with AI agents
In `@core/typed-nocodb-api/src/index.ts`:
- Around line 33-36: The condition for building referenceSchema is inverted and
unsafe for undefined: change the branch to use z.record(z.enum(...)) only when
references is a non-empty array (e.g., if (Array.isArray(references) &&
references.length > 0)), otherwise return z.object({}); also ensure you satisfy
z.enum's non-empty-tuple requirement by narrowing or casting references to a
non-empty tuple (or use a type guard/assert) before passing it into z.enum so
schema construction cannot throw at runtime.
Checklist
mainhave been mergedmain