Skip to content

Adaption to the new proxy format - #6

Closed
axlistas wants to merge 6 commits into
Enkryptify:mainfrom
axlistas:main
Closed

Adaption to the new proxy format#6
axlistas wants to merge 6 commits into
Enkryptify:mainfrom
axlistas:main

Conversation

@axlistas

@axlistas axlistas commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Change from Config{} to dynamic url support.

Summary by CodeRabbit

  • Documentation

    • Simplified proxy request examples in documentation.
  • Refactor

    • Restructured proxy request format to encode routing parameters (workspace, project, environment) in the URL path and use a simplified request body structure for improved efficiency and clarity.

axlistas and others added 3 commits April 30, 2026 13:53
Align proxy requests with backend routing by putting
workspace/project/environment in the proxy URL path.

Remove config and is-personal from the wire payload
to match the proxy request schema.

Made-with: Cursor
@coderabbitai

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown

Walkthrough

This PR restructures the proxy wire payload shape from a nested config object to top-level fields. The workspace, project, "environment-id", and "is-personal" properties are moved from config to the top level in ProxyWireBody. The proxy request URL construction is updated to append the scope path ({workspace}/{project}/{environment-id}) to the base proxy URL. A new buildProxyRequestUrl helper normalizes the URL and encodes path segments. Both the interceptor and proxy implementations are updated to reflect this change, and tests are adjusted to validate the new URL structure and payload shape.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • feat: add interceptor #4: Directly modifies the interceptor and proxy code patterns introduced in that PR to change the proxy wire payload shape and request URL construction.
  • feat: added support for proxy #3: Updates the proxy implementation introduced in PR #3 by restructuring the wire payload shape and modifying how proxy request URLs are constructed.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Adaption to the new proxy format' directly describes the main change: migrating from a nested config object to a top-level fields and dynamic URL-based proxy format.
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.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

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

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/proxy.test.ts`:
- Line 50: The tests have inconsistent expectations for the proxy base path:
update the assertions that verify the generated proxy URL (the
expect(url).toBe(...) checks in tests that exercise the proxy URL generation) so
both cases match the configured base which includes the "/v1/proxy" prefix;
adjust the two failing expectations (the one currently expecting
"https://proxy.test.com/v1/proxy/ws-1/prj-1/env-1" and the other default
expectation that omits "/v1/proxy") so they consistently assert the same full
base (include "/v1/proxy" if the configured base includes it).
🪄 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: 4dcb1e64-75e0-43cb-8d28-b051cce87780

📥 Commits

Reviewing files that changed from the base of the PR and between acb9e05 and 38e7e89.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • README.md
  • src/enkryptify.ts
  • src/interceptor.ts
  • src/proxy.ts
  • src/types.ts
  • tests/interceptor.test.ts
  • tests/proxy.test.ts
💤 Files with no reviewable changes (2)
  • README.md
  • src/types.ts

Comment thread tests/proxy.test.ts Outdated
@axlistas
axlistas marked this pull request as draft April 30, 2026 12:21
@axlistas
axlistas marked this pull request as ready for review April 30, 2026 12:25
Comment thread src/types.ts
Comment thread src/enkryptify.ts Outdated
Bring back usePersonal support for proxy requests and interceptor
rules by restoring is-personal on the proxy wire payload.

Set the default proxy base URL back to the root host path
instead of /v1/proxy and align tests accordingly.

Made-with: Cursor

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

🧹 Nitpick comments (1)
tests/proxy.test.ts (1)

229-257: ⚡ Quick win

Add one URL-encoding regression test for scoped path segments.

Current URL assertions only use safe slugs. Add a case with spaces/slashes to lock in encodeURIComponent behavior from src/proxy.ts (Line 312-315).

Suggested test addition
 describe("client.proxy.request — low-level API", () => {
+    it("encodes workspace/project/environment when building proxy URL path", async () => {
+        fetchMock.mockResolvedValue(new Response("{}", { status: 200 }));
+        const client = new Enkryptify(makeConfig());
+
+        await client.proxy.request({
+            url: "https://upstream/x",
+            method: "GET",
+            workspace: "team a",
+            project: "proj/blue",
+            environment: "env#1",
+        });
+
+        expect(fetchMock.mock.calls[0]?.[0]).toBe(
+            "https://proxy.test.com/team%20a/proj%2Fblue/env%231",
+        );
+    });
+
     it("applies per-call environment override", async () => {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/proxy.test.ts` around lines 229 - 257, Add a regression test that
verifies URL-encoding of scoped path segments by calling client.proxy.request
with workspace, project, and environment values containing spaces and slashes
(e.g., "my ws", "prj/with/slash", "env with/slash") and assert the proxied URL
used in fetchMock is the encoded form produced by encodeURIComponent for each
segment; reuse the existing test pattern (fetchMock.mockResolvedValue, new
Enkryptify(makeConfig()), await client.proxy.request(...),
getCallBody(fetchMock.mock.calls[0]) and expect(fetchMock.mock.calls[0]?.[0]) to
equal the proxy base plus the three segments encoded) to lock in the
encodeURIComponent behavior referenced in src/proxy.ts (client.proxy.request).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/proxy.test.ts`:
- Around line 229-257: Add a regression test that verifies URL-encoding of
scoped path segments by calling client.proxy.request with workspace, project,
and environment values containing spaces and slashes (e.g., "my ws",
"prj/with/slash", "env with/slash") and assert the proxied URL used in fetchMock
is the encoded form produced by encodeURIComponent for each segment; reuse the
existing test pattern (fetchMock.mockResolvedValue, new
Enkryptify(makeConfig()), await client.proxy.request(...),
getCallBody(fetchMock.mock.calls[0]) and expect(fetchMock.mock.calls[0]?.[0]) to
equal the proxy base plus the three segments encoded) to lock in the
encodeURIComponent behavior referenced in src/proxy.ts (client.proxy.request).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b23df8c5-b400-479f-9922-026eaf9c39cb

📥 Commits

Reviewing files that changed from the base of the PR and between 0198ecb and 6c71cbf.

📒 Files selected for processing (4)
  • src/interceptor.ts
  • src/proxy.ts
  • tests/interceptor.test.ts
  • tests/proxy.test.ts

@axlistas axlistas closed this Jun 2, 2026
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