Skip to content

fix: update ci for typescript openapi.json drift - #1464

Merged
het0814 merged 2 commits into
mainfrom
fix/openapi-ci
Jul 14, 2026
Merged

het0814 merged 2 commits into
mainfrom
fix/openapi-ci

Conversation

@het0814

@het0814 het0814 commented Jul 14, 2026 •

Copy link
Copy Markdown
Collaborator
  • fix openapi-drift CI

Summary by CodeRabbit

  • Documentation

    • Updated the TypeScript SDK’s OpenAPI specification with refreshed metadata, descriptions, and numeric validation details.
  • Chores

    • Added a consistent process for regenerating the OpenAPI specification locally and in automated checks.
    • Updated SDK tooling to generate the specification directly instead of fetching it from a running server.
    • Improved consistency checks to detect specification drift.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/openapi-ci

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
sdks/typescript/scripts/fetch-openapi.mjs (1)

10-15: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use script-relative paths instead of process.cwd() for better robustness.

Relying on process.cwd() assumes this script is always executed from the sdks/typescript directory. While this holds true when run via npm run, using URL-based path resolution (import.meta.url) makes the script resilient and safely executable from any working directory.

🛠️ Proposed refactor for script-relative paths
 import { spawnSync } from "node:child_process";
 import { writeFileSync } from "node:fs";
-import { resolve } from "node:path";
+import { dirname, resolve } from "node:path";
+import { fileURLToPath } from "node:url";
 
-const repoRoot = resolve(process.cwd(), "..", "..");
-const out = resolve(process.cwd(), "openapi.json");
+const __dirname = dirname(fileURLToPath(import.meta.url));
+const repoRoot = resolve(__dirname, "..", "..", "..");
+const out = resolve(__dirname, "..", "openapi.json");
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sdks/typescript/scripts/fetch-openapi.mjs` around lines 10 - 15, Update the
path setup around repoRoot and out to resolve locations from the script’s own
URL via import.meta.url instead of process.cwd(). Ensure repoRoot still points
to the repository root and out still targets the TypeScript SDK’s openapi.json,
regardless of the caller’s working directory.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/generate_openapi.py`:
- Around line 12-19: Remove the VERSION_FILE write and fallback-file mutation
from the OpenAPI generation setup. After importing the FastAPI app via
memanto.app.main.app, temporarily set its version attribute to FALLBACK_VERSION
before schema generation, preserving the real source-controlled _version.py and
avoiding changes to the local source tree.

---

Nitpick comments:
In `@sdks/typescript/scripts/fetch-openapi.mjs`:
- Around line 10-15: Update the path setup around repoRoot and out to resolve
locations from the script’s own URL via import.meta.url instead of
process.cwd(). Ensure repoRoot still points to the repository root and out still
targets the TypeScript SDK’s openapi.json, regardless of the caller’s working
directory.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: be29d580-624e-4998-af68-3960a910c268

📥 Commits

Reviewing files that changed from the base of the PR and between 95e677d and 3386b2d.

📒 Files selected for processing (4)
  • .github/workflows/sdk-typescript.yml
  • scripts/generate_openapi.py
  • sdks/typescript/openapi.json
  • sdks/typescript/scripts/fetch-openapi.mjs

Comment on lines +12 to +19
from pathlib import Path

FALLBACK_VERSION = "0.0.0.dev0"
VERSION_FILE = Path(__file__).resolve().parent.parent / "memanto" / "app" / "_version.py"

VERSION_FILE.write_text(f'__version__ = "{FALLBACK_VERSION}"\n')

from memanto.app.main import app # noqa: E402

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Avoid mutating source files to override the OpenAPI version.

Overwriting _version.py permanently modifies the local source tree, which can cause the local application to report the fallback version instead of the real hatch-vcs version until the environment is rebuilt.

You can achieve the same drift-free OpenAPI generation by dynamically overriding the version attribute on the FastAPI app instance before generating the schema.

♻️ Proposed fix to dynamically override the version
-from pathlib import Path
-
-FALLBACK_VERSION = "0.0.0.dev0"
-VERSION_FILE = Path(__file__).resolve().parent.parent / "memanto" / "app" / "_version.py"
-
-VERSION_FILE.write_text(f'__version__ = "{FALLBACK_VERSION}"\n')
-
-from memanto.app.main import app  # noqa: E402
+from memanto.app.main import app
 
+app.version = "0.0.0.dev0"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from pathlib import Path
FALLBACK_VERSION = "0.0.0.dev0"
VERSION_FILE = Path(__file__).resolve().parent.parent / "memanto" / "app" / "_version.py"
VERSION_FILE.write_text(f'__version__ = "{FALLBACK_VERSION}"\n')
from memanto.app.main import app # noqa: E402
from memanto.app.main import app
app.version = "0.0.0.dev0"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/generate_openapi.py` around lines 12 - 19, Remove the VERSION_FILE
write and fallback-file mutation from the OpenAPI generation setup. After
importing the FastAPI app via memanto.app.main.app, temporarily set its version
attribute to FALLBACK_VERSION before schema generation, preserving the real
source-controlled _version.py and avoiding changes to the local source tree.

@het0814
het0814 merged commit 47e91c6 into main Jul 14, 2026
9 checks passed
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.

2 participants