Skip to content
This repository was archived by the owner on Sep 21, 2026. It is now read-only.

[codex] Update reference specs and markdown generation - #2834

Merged
ChiragAgg5k merged 3 commits into
mainfrom
codex/update-reference-specs-and-markdown
Mar 29, 2026
Merged

ChiragAgg5k merged 3 commits into
mainfrom
codex/update-reference-specs-and-markdown

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Mar 29, 2026 •

Copy link
Copy Markdown
Member

Summary

This PR updates the website references stack to use a newer @appwrite.io/specs revision and hardens reference markdown generation in development.

What changed

  • bump @appwrite.io/specs in package.json and bun.lock
  • add 1.9.x to the references version list and example loader
  • make src/lib/system.ts tolerate a missing optional PUBLIC_ARENA_ENDPOINT export in dev
  • make dynamic reference markdown generation ignore placeholder route ids like [version]
  • make OpenAPI spec lookup resolve by filename suffix so it works with the built glob keys in dev/server output

Why

There were two related failures in local development:

  • the dev client could fail to hydrate when PUBLIC_ARENA_ENDPOINT was unset because $env/static/public did not export that name
  • service markdown generation could fail when dynamic markdown was invoked with placeholder route ids or when the generated spec glob keys did not match the hardcoded path used by getApi

Impact

  • reference pages can load in dev without the optional arena env var being defined
  • generated reference markdown for real routes continues to work
  • placeholder route ids no longer try to resolve fake spec files
  • 1.9.x reference assets are available after the specs bump

Validation

  • verified the generated markdown route returns successfully:
    • curl http://127.0.0.1:4173/docs/references/cloud/client-web/account.md
  • verified the branch pushed successfully to GitHub

Notes

  • gh auth status is currently invalid in this environment, so the PR was created through the GitHub connector instead of the CLI.

Summary by CodeRabbit

  • New Features

    • Added support for version 1.9.x with associated documentation examples.
  • Documentation

    • Improved spec/example loading and handling so docs resolve correctly across versions and platforms.
    • Markdown generation now skips placeholder-style route segments to avoid publishing incomplete route docs.
  • Chores

    • Updated a dev dependency reference and adjusted internal environment handling.

@coderabbitai

coderabbitai Bot commented Mar 29, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

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

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 4 minutes and 0 seconds.

⌛ 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ead3723a-39e4-4d5f-9c18-f19e556557ab

📥 Commits

Reviewing files that changed from the base of the PR and between 16708e4 and cde7dd3.

📒 Files selected for processing (2)
  • src/lib/server/model-markdown.ts
  • src/routes/docs/references/[version]/models/[model]/+page.server.ts

Walkthrough

This pull request updates the devDependency reference for @appwrite.io/specs to a different commit, adds support for version 1.9.x in the version registry, introduces an isRoutePlaceholder() check in markdown generators to skip placeholder path parameters, changes public environment imports in src/lib/system.ts to use a dynamic publicEnv object, and refactors spec/example loading in src/routes/docs/references/.../specs.ts to select loaders by filename, await async loaders, handle default exports, and return undefined for missing examples.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

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.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes across the PR: updating specs version, adding version support, and hardening markdown generation with placeholder handling.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/update-reference-specs-and-markdown

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.

@ChiragAgg5k
ChiragAgg5k marked this pull request as ready for review March 29, 2026 09:34
@greptile-apps

greptile-apps Bot commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR hardens reference page loading in local development by bumping @appwrite.io/specs to include 1.9.x assets, fixing a SvelteKit hydration failure caused by a missing optional PUBLIC_ARENA_ENDPOINT export, preventing the markdown generator from attempting spec resolution when invoked with SvelteKit route-placeholder strings (e.g. [version]), and making getApi resolve its OpenAPI spec by filename suffix rather than a hard-coded glob key that does not match the format produced by the Vite build.

  • package.json / bun.lock: deps bump to @appwrite.io/specs#bd8ee02
  • src/lib/utils/references.ts: 1.9.x added as the newest entry in allVersions
  • src/lib/system.ts: namespace import + type cast makes PUBLIC_ARENA_ENDPOINT optional, preventing a crash when the variable is absent in .env
  • src/lib/server/markdown-generators.ts: new isRoutePlaceholder helper guards both generators and returns null early for any route segment that is a SvelteKit placeholder like [version]
  • specs.ts: getExamples gains a 1.9.x case; getApi now uses Object.entries(specs).find(key.endsWith(…)) instead of an exact path string, making the lookup resilient to different key formats between dev and production builds
  • Minor: the getExamples switch still lacks a default/cloud case; the existing if (!examples) guard makes this safe but a tidy-up would be nice

Confidence Score: 5/5

Safe to merge — all changes are focused dev-environment hardening with no risk to production behaviour

No P0 or P1 issues found. The only finding is a pre-existing missing default case in getExamples that is already handled gracefully by the surrounding null-guard, making it purely cosmetic. All logic changes are correct and well-targeted.

src/routes/docs/references/[version]/[platform]/[service]/specs.ts — minor: getExamples switch has no default/cloud case

Important Files Changed

Filename Overview
src/lib/server/markdown-generators.ts Adds isRoutePlaceholder helper and guards both generators to return null when any route segment is a SvelteKit placeholder like [version]; logic is correct and prevents spurious spec lookups in dev
src/lib/system.ts Switches to namespace import of $env/static/public and casts the type to mark PUBLIC_ARENA_ENDPOINT as optional, cleanly resolving the hydration failure when the env var is absent in dev
src/lib/utils/references.ts Adds 1.9.x as the newest entry in allVersions; consistent with the existing ordering convention
src/routes/docs/references/[version]/[platform]/[service]/specs.ts Adds 1.9.x to getExamples switch and refactors getApi to resolve the glob key by filename suffix rather than an exact path, handling dev vs build key format differences; default case still absent from getExamples switch
package.json Bumps @appwrite.io/specs to commit bd8ee02
bun.lock Lockfile updated to reflect the new @appwrite.io/specs commit hash

Reviews (1): Last reviewed commit: "Update reference specs and markdown gene..." | Re-trigger Greptile

Comment thread src/routes/docs/references/[version]/[platform]/[service]/specs.ts Outdated
Comment thread src/lib/system.ts Outdated

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

🧹 Nitpick comments (2)
src/routes/docs/references/[version]/[platform]/[service]/specs.ts (2)

93-150: This version switch is another sync point.

getExamples() now has to stay in sync with src/lib/utils/references.ts:5-24. A shared Record<Exclude<Version, 'cloud'>, ...> would let the compiler catch the next version bump instead of relying on another manual switch update.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/routes/docs/references/`[version]/[platform]/[service]/specs.ts around
lines 93 - 150, The getExamples function uses a manual switch per version;
instead export a single source-of-truth (e.g., a Record or array) from
src/lib/utils/references.ts (reference the exported symbol you add, e.g.,
VERSIONS or VERSION_MAP) and replace the switch in getExamples(version: string)
with a lookup against that exported record to build the import.meta.glob path(s)
programmatically; this way the compiler will surface missing versions and you
only update one Record (the symbol exported from src/lib/utils/references.ts)
instead of editing getExamples and the other file separately.

410-417: Prefer a 404 over a generic error for missing spec loaders.

Line 413 throws a plain Error, so a bad {version}/{platform} docs URL will read as a 500 unless something upstream converts it. If a missing loader here means “reference not found,” using SvelteKit’s error(404, ...) would keep this aligned with getSchema().

📦 Possible adjustment
     const loader = Object.entries(specs).find(([key]) => key.endsWith(`/${filename}`))?.[1];

     if (!loader) {
-        throw new Error(`Missing OpenAPI spec loader for ${filename}`);
+        error(404, { message: 'Not found' });
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/routes/docs/references/`[version]/[platform]/[service]/specs.ts around
lines 410 - 417, Replace the generic throw with SvelteKit's 404 helper: import
error from '@sveltejs/kit' (or add it to existing imports) and change the
existing "throw new Error(`Missing OpenAPI spec loader for ${filename}`)" to
"throw error(404, `Missing OpenAPI spec loader for ${filename}`)"; keep the
surrounding loader lookup and the subsequent loading/return logic (the loader
variable and the loaded/default branching) unchanged so the function behavior is
identical except for returning a 404 when the spec loader is missing, matching
getSchema().
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/routes/docs/references/`[version]/[platform]/[service]/specs.ts:
- Around line 93-150: The getExamples function uses a manual switch per version;
instead export a single source-of-truth (e.g., a Record or array) from
src/lib/utils/references.ts (reference the exported symbol you add, e.g.,
VERSIONS or VERSION_MAP) and replace the switch in getExamples(version: string)
with a lookup against that exported record to build the import.meta.glob path(s)
programmatically; this way the compiler will surface missing versions and you
only update one Record (the symbol exported from src/lib/utils/references.ts)
instead of editing getExamples and the other file separately.
- Around line 410-417: Replace the generic throw with SvelteKit's 404 helper:
import error from '@sveltejs/kit' (or add it to existing imports) and change the
existing "throw new Error(`Missing OpenAPI spec loader for ${filename}`)" to
"throw error(404, `Missing OpenAPI spec loader for ${filename}`)"; keep the
surrounding loader lookup and the subsequent loading/return logic (the loader
variable and the loaded/default branching) unchanged so the function behavior is
identical except for returning a 404 when the spec loader is missing, matching
getSchema().

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 69886fb6-0dad-476d-ba54-4eac4d35e975

📥 Commits

Reviewing files that changed from the base of the PR and between 94418f2 and f5c8ffa.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • package.json
  • src/lib/server/markdown-generators.ts
  • src/lib/system.ts
  • src/lib/utils/references.ts
  • src/routes/docs/references/[version]/[platform]/[service]/specs.ts

@ChiragAgg5k
ChiragAgg5k merged commit 4a6b058 into main Mar 29, 2026
6 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants