Skip to content

fix: some provider proxy impl - #51

Merged
l1shen merged 2 commits into
oomol-lab:mainfrom
l1shen:intact-toad
Jul 7, 2026
Merged

fix: some provider proxy impl#51
l1shen merged 2 commits into
oomol-lab:mainfrom
l1shen:intact-toad

Conversation

@l1shen

@l1shen l1shen commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f446666b-9210-47fa-a7e6-6f422492898c

📥 Commits

Reviewing files that changed from the base of the PR and between d45d504 and 1a0392e.

📒 Files selected for processing (2)
  • src/providers/prerender/executors.ts
  • src/providers/provider-proxy-loader-n-s.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/providers/provider-proxy-loader-n-s.test.ts
  • src/providers/prerender/executors.ts

Summary by CodeRabbit

  • New Features
    • Expanded proxy routing for multiple providers, including Builder.io, Google Docs/Drive/Sheets, and Prerender.
    • Hugging Face now supports API key authentication in addition to OAuth.
  • Bug Fixes
    • Added stricter endpoint selection and unsupported-endpoint errors for provider proxies.
    • Improved request/credential handling to ensure correct auth headers and URL construction.
  • Tests
    • Added/extended Vitest coverage for Hugging Face executor behavior and multiple provider proxy-loader routing scenarios.

Walkthrough

This PR adds provider-specific proxy executors for Builder.io, Google Docs, and Prerender, with path-based routing and request normalization. It extends Hugging Face to support both OAuth2 and API key authentication across provider definition, runtime context, executor wiring, and validation. It also updates the proxy registry for forem, semantic_scholar, huggingface, posthog, and tiktok_business, and adds proxy-loader tests for the new and updated routing and auth flows.

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided, so there is no meaningful text to assess against the changeset. Add a brief description of the provider proxy updates and affected providers.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the required fix-prefixed format and is related to the provider proxy changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 (2)
src/providers/huggingface/runtime.shared.ts (1)

352-371: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract hardcoded profile URL into a named constant.

The rest of the file defines endpoint URLs as top-level constants (huggingfaceUserinfoUrl, huggingfaceWhoamiUrl, etc.), but this function inlines https://huggingface.co/${preferredUsername} directly.

♻️ Proposed refactor
+export const huggingfaceProfileBaseUrl = "https://huggingface.co";
+
 function normalizeTokenCurrentUserPayload(payload: Record<string, unknown>): HuggingfaceCurrentUser {
   const user: HuggingfaceCurrentUser = {
     id: optionalString(payload.id) ?? requireProviderString(payload.name, "huggingface user name"),
   };
   const preferredUsername = optionalString(payload.name);
   if (preferredUsername) {
     user.preferredUsername = preferredUsername;
-    user.profileUrl = `https://huggingface.co/${preferredUsername}`;
+    user.profileUrl = `${huggingfaceProfileBaseUrl}/${preferredUsername}`;
   }
🤖 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 `@src/providers/huggingface/runtime.shared.ts` around lines 352 - 371, The
profile URL in normalizeTokenCurrentUserPayload is hardcoded inline, unlike the
other endpoint URLs in this module. Add a top-level named constant for the
Hugging Face profile base URL and use it when setting user.profileUrl, keeping
the URL construction in normalizeTokenCurrentUserPayload consistent and easier
to maintain.
src/providers/huggingface/executors.test.ts (1)

1-52: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add oauth2 coverage alongside the new api_key test.

This new file only tests the api_key path for huggingface.get_current_user. The oauth2 branch of createContext (and its distinct huggingfaceUserinfoUrl request/normalization path) has no coverage here.

🤖 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 `@src/providers/huggingface/executors.test.ts` around lines 1 - 52, Add test
coverage for the oauth2 branch in Hugging Face executors. Extend the
`executors["huggingface.get_current_user"]` tests to cover `createContext` when
`getCredential` returns an oauth2 credential, and assert it calls the
`huggingfaceUserinfoUrl` path instead of `whoami-v2`. Verify the response
normalization matches the oauth2 userinfo shape and that the resulting `output`
fields are mapped correctly, alongside the existing `apiKeyCredential` test.
🤖 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 `@src/providers/prerender/executors.ts`:
- Around line 184-196: Normalize the method in buildPrerenderProxyRequest before
the GET/POST branching, because ProxyRequestInput.method is a plain string and
exact-case checks can miss lowercase or mixed-case values. Update the logic
around buildPrerenderProxyRequest to compare against a normalized method value
(for example, a consistent uppercase form) so the cache-clear-status token
rewrite and POST body rewrite still happen regardless of input casing.

---

Nitpick comments:
In `@src/providers/huggingface/executors.test.ts`:
- Around line 1-52: Add test coverage for the oauth2 branch in Hugging Face
executors. Extend the `executors["huggingface.get_current_user"]` tests to cover
`createContext` when `getCredential` returns an oauth2 credential, and assert it
calls the `huggingfaceUserinfoUrl` path instead of `whoami-v2`. Verify the
response normalization matches the oauth2 userinfo shape and that the resulting
`output` fields are mapped correctly, alongside the existing `apiKeyCredential`
test.

In `@src/providers/huggingface/runtime.shared.ts`:
- Around line 352-371: The profile URL in normalizeTokenCurrentUserPayload is
hardcoded inline, unlike the other endpoint URLs in this module. Add a top-level
named constant for the Hugging Face profile base URL and use it when setting
user.profileUrl, keeping the URL construction in
normalizeTokenCurrentUserPayload consistent and easier to maintain.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b4be59f9-c68a-46d3-84b8-eeb89bd16ce0

📥 Commits

Reviewing files that changed from the base of the PR and between 9e4afe0 and d45d504.

📒 Files selected for processing (13)
  • src/providers/builder_io/executors.ts
  • src/providers/googledocs/executors.ts
  • src/providers/huggingface/definition.ts
  • src/providers/huggingface/executors.test.ts
  • src/providers/huggingface/executors.ts
  • src/providers/huggingface/runtime.shared.ts
  • src/providers/prerender/executors.ts
  • src/providers/provider-proxy-loader-a-c.test.ts
  • src/providers/provider-proxy-loader-d-g.test.ts
  • src/providers/provider-proxy-loader-h-m.test.ts
  • src/providers/provider-proxy-loader-n-s.test.ts
  • src/providers/provider-proxy-loader-t-z.test.ts
  • src/providers/proxy.registry.ts

Comment thread src/providers/prerender/executors.ts
@l1shen
l1shen merged commit 2adc9df into oomol-lab:main Jul 7, 2026
2 checks passed
@l1shen
l1shen deleted the intact-toad branch July 8, 2026 02:10
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