Skip to content

chore: update record id type to number in response schema#205

Open
stephansama wants to merge 7 commits intomainfrom
stephansama/ste-78-fix-references-implementation-for-nocodb-api
Open

chore: update record id type to number in response schema#205
stephansama wants to merge 7 commits intomainfrom
stephansama/ste-78-fix-references-implementation-for-nocodb-api

Conversation

@stephansama
Copy link
Copy Markdown
Owner

Checklist

  • Latest changes from main have been merged
  • Conflicts have been resolved
  • The branch is pointing to main
  • Eslint hasn't reported any issues.
  • All unit tests pass

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 10, 2026

🦋 Changeset detected

Latest commit: d5704e3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@stephansama/typed-nocodb-api Minor

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

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
packages Ready Ready Preview, Comment Feb 10, 2026 11:20pm

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @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

  • Schema Type Correction: The id field within the records array in the response schema for the createApi function has been updated from z.string() to z.number(). This ensures type correctness for record IDs.

🧠 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
  • core/typed-nocodb-api/src/index.ts
    • Updated the id type within the records array of the responseSchema from z.string() to z.number().
Activity
  • No specific review comments or activity have been recorded for this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 10, 2026

Warning

Rate limit exceeded

@stephansama has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 34 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📝 Walkthrough

Walkthrough

Added a generic References parameter and references? argument to createApi, introduced a computed referenceSchema, and updated CREATE/LIST/UPDATE schemas to include fields: schema.and(referenceSchema) and use id: number consistently; tests and changeset updated accordingly.

Changes

Cohort / File(s) Summary
API Type & Signature
core/typed-nocodb-api/src/index.ts
Added generic References extends Array<string> and references?: References; introduced referenceSchema and changed CREATE/LIST/UPDATE schemas to use fields: schema.and(referenceSchema) and id: number.
Tests
core/typed-nocodb-api/test/index.test.ts
Updated test mocks and assertions: record id values changed from string "123" to number 123; UPDATE test now returns the mocked response.
Release / Changeset
.changeset/great-ends-dream.md
Added changeset noting package bump and references implementation update.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 I dug through types with curious nose,

swapped quoted ids for tidy rows.
References tucked into schema's seam,
records now match the coder's dream.
✨🥕

🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive The PR partially addresses STE-78 by fixing references implementation (adding optional references parameter and referenceSchema), but the core objective of making references conditionally required is not fully documented in the description. Clarify in the description how references are now conditionally required based on the action, and explicitly document the conditional logic implemented for different API actions.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: updating the record id type from string to number in response schemas across CREATE, LIST, and UPDATE endpoints.
Description check ✅ Passed The description follows the provided template with all checklist items completed, covering merge status, conflict resolution, branch pointing, linting, and test passing.
Out of Scope Changes check ✅ Passed All changes are within scope: id type updates to number, references parameter addition, referenceSchema implementation, and test updates align with STE-78 references implementation fix.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch stephansama/ste-78-fix-references-implementation-for-nocodb-api

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 10, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
core/typed-nocodb-api/src/index.ts 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread core/typed-nocodb-api/src/index.ts Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 | 🟠 Major

UPDATE inputSchema still types id as z.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 UPDATE inputSchema on line 76 still uses z.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".

Comment thread core/typed-nocodb-api/src/index.ts
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 10, 2026

More templates

@stephansama/ai-commit-msg

pnpm add https://pkg.pr.new/stephansama/packages/@stephansama/ai-commit-msg@205

@stephansama/alfred-kaomoji

pnpm add https://pkg.pr.new/stephansama/packages/@stephansama/alfred-kaomoji@205

@stephansama/astro-iconify-svgmap

pnpm add https://pkg.pr.new/stephansama/packages/@stephansama/astro-iconify-svgmap@205

@stephansama/auto-readme

pnpm add https://pkg.pr.new/stephansama/packages/@stephansama/auto-readme@205

@stephansama/catppuccin-opml

pnpm add https://pkg.pr.new/stephansama/packages/@stephansama/catppuccin-opml@205

@stephansama/catppuccin-rss

pnpm add https://pkg.pr.new/stephansama/packages/@stephansama/catppuccin-rss@205

@stephansama/catppuccin-typedoc

pnpm add https://pkg.pr.new/stephansama/packages/@stephansama/catppuccin-typedoc@205

@stephansama/catppuccin-xsl

pnpm add https://pkg.pr.new/stephansama/packages/@stephansama/catppuccin-xsl@205

create-stephansama-example

pnpm add https://pkg.pr.new/stephansama/packages/create-stephansama-example@205

@stephansama/find-makefile-targets

pnpm add https://pkg.pr.new/stephansama/packages/@stephansama/find-makefile-targets@205

@stephansama/github-env

pnpm add https://pkg.pr.new/stephansama/packages/@stephansama/github-env@205

@stephansama/multipublish

pnpm add https://pkg.pr.new/stephansama/packages/@stephansama/multipublish@205

@stephansama/prettier-plugin-handlebars

pnpm add https://pkg.pr.new/stephansama/packages/@stephansama/prettier-plugin-handlebars@205

@stephansama/remark-asciinema

pnpm add https://pkg.pr.new/stephansama/packages/@stephansama/remark-asciinema@205

@stephansama/svelte-social-share-links

pnpm add https://pkg.pr.new/stephansama/packages/@stephansama/svelte-social-share-links@205

@stephansama/typed-events

pnpm add https://pkg.pr.new/stephansama/packages/@stephansama/typed-events@205

@stephansama/typed-nocodb-api

pnpm add https://pkg.pr.new/stephansama/packages/@stephansama/typed-nocodb-api@205

@stephansama/typed-templates

pnpm add https://pkg.pr.new/stephansama/packages/@stephansama/typed-templates@205

commit: d5704e3

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 | 🟠 Major

No test coverage for the new references parameter.

The references feature is the main addition in this PR, but no test exercises createApi with a references array. Given the inverted-condition bug flagged in the source file, a test would have caught it immediately. Consider adding at least one test that passes references: ["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 | 🟡 Minor

READ response schema should include referenceSchema intersection

READ is the only record-returning action using fields: schema without referenceSchema. CREATE, LIST, and UPDATE all compose fields: 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.

Comment thread core/typed-nocodb-api/src/index.ts
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