-
Notifications
You must be signed in to change notification settings - Fork 54
Add stripe-customer-id header to GitHub ingest flow #2289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
Finished running flow.
|
||||||||||||||||||
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds a shared Changes
Sequence DiagramsequenceDiagram
participant Orch as process-repository
participant Builder as buildAiGatewayHeaders
participant Blobs as ingestGitHubBlobs
participant Issues as ingestGitHubIssues
participant PRs as ingestGitHubPullRequests
participant Pipeline as IngestPipeline
participant Embed as EmbedderConfig
Orch->>Builder: buildAiGatewayHeaders(team)
Builder-->>Orch: headers
Orch->>Blobs: ingestGitHubBlobs(..., headers)
Blobs->>Pipeline: createPipeline({..., headers})
Pipeline->>Embed: propagate headers when gateway enabled
Orch->>Issues: ingestGitHubIssues(..., headers)
Issues->>Pipeline: createPipeline({..., headers})
Pipeline->>Embed: propagate headers when gateway enabled
Orch->>PRs: ingestGitHubPullRequests(..., headers)
PRs->>Pipeline: createPipeline({..., headers})
Pipeline->>Embed: propagate headers when gateway enabled
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements Stripe customer ID header propagation for GitHub repository ingestion flows to enable proper billing attribution through the AI Gateway. The implementation creates a shared header building function and integrates it across all GitHub content type ingestion paths (blobs, PRs, issues) while refactoring document ingestion to use the same shared utility.
- Adds shared
buildAiGatewayHeadersfunction for consistent header construction across all vector store ingest flows - Extends ingest pipeline to support optional headers parameter for AI Gateway requests
- Integrates Stripe customer ID headers into GitHub blob, PR, and issue ingest functions
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/studio.giselles.ai/lib/vector-stores/shared/ai-gateway-headers.ts | New shared utility function for building AI Gateway headers with Stripe customer ID |
| packages/rag/src/ingest/pipeline.ts | Added optional headers parameter to pipeline options and passes them to embedder when using gateway |
| apps/studio.giselles.ai/lib/vector-stores/github/ingest/process-repository.ts | Builds AI Gateway headers and passes them to blob, PR, and issue ingest functions |
| apps/studio.giselles.ai/lib/vector-stores/github/ingest/blobs/ingest-github-blobs.ts | Added headers parameter to support AI Gateway billing attribution |
| apps/studio.giselles.ai/lib/vector-stores/github/ingest/pull-requests/ingest-github-pull-requests.ts | Added headers parameter to support AI Gateway billing attribution |
| apps/studio.giselles.ai/lib/vector-stores/github/ingest/issues/ingest-github-issues.ts | Added headers parameter to support AI Gateway billing attribution |
| apps/studio.giselles.ai/lib/vector-stores/document/ingest/ingest-document.ts | Refactored to use shared buildAiGatewayHeaders function instead of local implementation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ); | ||
| } | ||
|
|
||
| return headers; |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function always returns headers even when empty (only containing http-referer and x-title). For consistency with the original document ingest implementation and to avoid passing unnecessary headers when not using the gateway, consider returning undefined when no Stripe customer ID is present and the team is not on a paid plan.
| return headers; | |
| if (stripeCustomerId !== undefined || team?.plan === "pro" || team?.plan === "team") { | |
| return headers; | |
| } | |
| return undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion! I'd prefer to keep the current behavior for the following reasons:
http-referer and x-title are useful for request tracking on the AI Gateway side, independent of Stripe billing
attribution. If we return undefined for non-paid users, we'd lose this tracking capability for their requests as well.
Also, looking at generate-embeddings.ts:111, headers are only applied when using the gateway:
headers: useGateway ? headers : undefined,
So there's no concern about passing unnecessary headers when not using the gateway.
| }, | ||
| }); | ||
|
|
||
| const headers = buildAiGatewayHeaders(team); |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The headers are built three separate times for each content type (blobs, PRs, issues), but they depend only on the team which is the same for all three. Consider building the headers once before the switch statement and reusing them across all content processors to avoid redundant computation.
| }, | ||
| }); | ||
|
|
||
| const headers = buildAiGatewayHeaders(team); |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The headers are built three separate times for each content type (blobs, PRs, issues), but they depend only on the team which is the same for all three. Consider building the headers once before the switch statement and reusing them across all content processors to avoid redundant computation.
| }, | ||
| }); | ||
|
|
||
| const headers = buildAiGatewayHeaders(team); |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The headers are built three separate times for each content type (blobs, PRs, issues), but they depend only on the team which is the same for all three. Consider building the headers once before the switch statement and reusing them across all content processors to avoid redundant computation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback!
I considered this, but I'd prefer to keep the current structure for a couple of reasons:
- buildAiGatewayHeaders is a lightweight function (simple object creation with a conditional), so the performance impact of calling it multiple times is negligible.
- Each processor in CONTENT_PROCESSORS is currently self-contained, handling its own dependencies. Passing headers from outside would add coupling between the caller and processors.
That said, if this becomes a concern in the future (e.g., if the function becomes more expensive), we can easily refactor it then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
apps/studio.giselles.ai/lib/vector-stores/document/ingest/ingest-document.ts(2 hunks)apps/studio.giselles.ai/lib/vector-stores/github/ingest/blobs/ingest-github-blobs.ts(2 hunks)apps/studio.giselles.ai/lib/vector-stores/github/ingest/issues/ingest-github-issues.ts(2 hunks)apps/studio.giselles.ai/lib/vector-stores/github/ingest/process-repository.ts(4 hunks)apps/studio.giselles.ai/lib/vector-stores/github/ingest/pull-requests/ingest-github-pull-requests.ts(2 hunks)apps/studio.giselles.ai/lib/vector-stores/shared/ai-gateway-headers.ts(1 hunks)packages/rag/src/ingest/pipeline.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx,js,jsx}: Favor clear, descriptive names and type annotations over clever tricks
If you need a multi-paragraph comment, refactor until intent is obvious
**/*.{ts,tsx,js,jsx}: Use async/await and proper error handling
Variables and functions should use camelCase naming
Booleans and functions should useis,has,can,shouldprefixes
Function names should clearly indicate purpose
Files:
apps/studio.giselles.ai/lib/vector-stores/shared/ai-gateway-headers.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/issues/ingest-github-issues.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/pull-requests/ingest-github-pull-requests.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/blobs/ingest-github-blobs.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/process-repository.tspackages/rag/src/ingest/pipeline.tsapps/studio.giselles.ai/lib/vector-stores/document/ingest/ingest-document.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development-guide.mdc)
**/*.{ts,tsx}: MUST runpnpm biome check --write [filename]after EVERY code modification
All code changes must be formatted using Biome before being committed
Use Biome for formatting with tab indentation and double quotes
Follow organized imports pattern (enabled in biome.json)
Use TypeScript for type safety; avoidanytypes
Use Next.js patterns for web applications
Use async/await for asynchronous code rather than promises
Error handling: use try/catch blocks and propagate errors appropriately
Use kebab-case for all filenames
Use PascalCase for React components and classes
Use camelCase for variables, functions, and methods
Use prefixes likeis,has,can,shouldfor boolean variables (e.g.,isEnabled,hasPermission)
Use prefixes likeis,has,can,shouldfor boolean functions (e.g.,isTriggerRequiringCallsign(),hasActiveSubscription()) instead of imperative verbs
Use verbs or verb phrases for function naming that clearly indicate purpose (e.g.,calculateTotalPrice(), notprocess())Use PascalCase for React component and class names
Use TypeScript and avoid
any
Files:
apps/studio.giselles.ai/lib/vector-stores/shared/ai-gateway-headers.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/issues/ingest-github-issues.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/pull-requests/ingest-github-pull-requests.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/blobs/ingest-github-blobs.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/process-repository.tspackages/rag/src/ingest/pipeline.tsapps/studio.giselles.ai/lib/vector-stores/document/ingest/ingest-document.ts
**/*.{js,ts,tsx,jsx,py,java,cs,cpp,c,go,rb,php,swift,kt,scala,rs,dart}
📄 CodeRabbit inference engine (.cursor/rules/language-support.mdc)
Write all code comments in English
Files:
apps/studio.giselles.ai/lib/vector-stores/shared/ai-gateway-headers.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/issues/ingest-github-issues.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/pull-requests/ingest-github-pull-requests.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/blobs/ingest-github-blobs.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/process-repository.tspackages/rag/src/ingest/pipeline.tsapps/studio.giselles.ai/lib/vector-stores/document/ingest/ingest-document.ts
**/*
📄 CodeRabbit inference engine (.cursor/rules/naming-guide.mdc)
Use kebab-case for file names (e.g.,
user-profile.ts,api-client.tsx)
Files:
apps/studio.giselles.ai/lib/vector-stores/shared/ai-gateway-headers.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/issues/ingest-github-issues.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/pull-requests/ingest-github-pull-requests.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/blobs/ingest-github-blobs.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/process-repository.tspackages/rag/src/ingest/pipeline.tsapps/studio.giselles.ai/lib/vector-stores/document/ingest/ingest-document.ts
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/naming-guide.mdc)
**/*.{js,ts,jsx,tsx}: Use camelCase for variable names, functions, and methods
Use verbs or verb phrases for function names to clearly indicate what the function does (e.g.,calculateTotalPrice(),validateUserInput())
Use nouns or noun phrases for variable names to describe what the variable represents
Use boolean prefixes (is,has,can,should) for boolean variables and functions returning boolean values (e.g.,isEnabled,hasPermission,isTriggerRequiringCallsign())
**/*.{js,ts,jsx,tsx}: Runpnpm biome check --write [filename]after every code change
All code must be formatted with Biome before commit
Files:
apps/studio.giselles.ai/lib/vector-stores/shared/ai-gateway-headers.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/issues/ingest-github-issues.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/pull-requests/ingest-github-pull-requests.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/blobs/ingest-github-blobs.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/process-repository.tspackages/rag/src/ingest/pipeline.tsapps/studio.giselles.ai/lib/vector-stores/document/ingest/ingest-document.ts
**/*.{ts,tsx,js,jsx,css}
📄 CodeRabbit inference engine (AGENTS.md)
Files should use kebab-case naming
Files:
apps/studio.giselles.ai/lib/vector-stores/shared/ai-gateway-headers.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/issues/ingest-github-issues.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/pull-requests/ingest-github-pull-requests.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/blobs/ingest-github-blobs.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/process-repository.tspackages/rag/src/ingest/pipeline.tsapps/studio.giselles.ai/lib/vector-stores/document/ingest/ingest-document.ts
**/*.{tsx,ts}
📄 CodeRabbit inference engine (AGENTS.md)
Components should use PascalCase naming
Files:
apps/studio.giselles.ai/lib/vector-stores/shared/ai-gateway-headers.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/issues/ingest-github-issues.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/pull-requests/ingest-github-pull-requests.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/blobs/ingest-github-blobs.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/process-repository.tspackages/rag/src/ingest/pipeline.tsapps/studio.giselles.ai/lib/vector-stores/document/ingest/ingest-document.ts
🧠 Learnings (1)
📚 Learning: 2025-11-25T03:07:07.498Z
Learnt from: CR
Repo: giselles-ai/giselle PR: 0
File: internal-packages/workflow-designer-ui/src/editor/properties-panel/trigger-node-properties-panel/providers/github-trigger/AGENTS.md:0-0
Timestamp: 2025-11-25T03:07:07.498Z
Learning: Applies to internal-packages/workflow-designer-ui/src/editor/properties-panel/trigger-node-properties-panel/providers/github-trigger/**/*.tsx : Build `GitHubFlowTriggerEvent` with optional callsign or labels properties and derive `outputs` from event payload keys before calling `client.configureTrigger()`.
Applied to files:
apps/studio.giselles.ai/lib/vector-stores/github/ingest/issues/ingest-github-issues.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/pull-requests/ingest-github-pull-requests.tsapps/studio.giselles.ai/lib/vector-stores/github/ingest/process-repository.ts
🧬 Code graph analysis (3)
apps/studio.giselles.ai/lib/vector-stores/shared/ai-gateway-headers.ts (2)
apps/studio.giselles.ai/services/teams/types.ts (1)
TeamWithSubscription(18-18)apps/studio.giselles.ai/next.config.ts (1)
headers(77-105)
apps/studio.giselles.ai/lib/vector-stores/github/ingest/process-repository.ts (3)
apps/studio.giselles.ai/lib/vector-stores/shared/ai-gateway-headers.ts (1)
buildAiGatewayHeaders(8-29)apps/studio.giselles.ai/lib/vector-stores/github/ingest/blobs/ingest-github-blobs.ts (1)
ingestGitHubBlobs(21-69)apps/studio.giselles.ai/lib/vector-stores/github/ingest/pull-requests/ingest-github-pull-requests.ts (1)
ingestGitHubPullRequests(23-73)
apps/studio.giselles.ai/lib/vector-stores/document/ingest/ingest-document.ts (1)
apps/studio.giselles.ai/lib/vector-stores/shared/ai-gateway-headers.ts (1)
buildAiGatewayHeaders(8-29)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Cursor Bugbot
- GitHub Check: check
🔇 Additional comments (9)
apps/studio.giselles.ai/lib/vector-stores/github/ingest/issues/ingest-github-issues.ts (1)
24-24: LGTM! Headers parameter properly propagated.The optional
headersparameter is correctly added to the function signature and properly propagated to the ingestion pipeline. This aligns with the pattern used in blob and pull request ingestion.Also applies to: 84-84
apps/studio.giselles.ai/lib/vector-stores/document/ingest/ingest-document.ts (1)
14-14: LGTM! Successfully refactored to use shared header builder.The refactoring consolidates header construction logic into the shared
buildAiGatewayHeadersfunction, eliminating code duplication. The call correctly passes the team from the telemetry context.Also applies to: 269-271
packages/rag/src/ingest/pipeline.ts (2)
49-50: LGTM! Optional headers parameter added to pipeline options.The addition of the optional
headersparameter toIngestPipelineOptionsenables header propagation through the ingestion pipeline.
119-119: LGTM! Headers correctly passed only when using gateway.The conditional logic ensures headers are only passed to the embedder when using the AI Gateway transport, which is the correct behavior since headers are only needed for gateway requests.
apps/studio.giselles.ai/lib/vector-stores/github/ingest/process-repository.ts (3)
18-18: LGTM! Headers properly constructed and passed for blob ingestion.The headers are built using the shared
buildAiGatewayHeadersfunction with the team context and correctly passed to theingestGitHubBlobsfunction.Also applies to: 80-80, 88-88
115-115: LGTM! Headers properly constructed and passed for pull request ingestion.The headers are built using the shared
buildAiGatewayHeadersfunction with the team context and correctly passed to theingestGitHubPullRequestsfunction.Also applies to: 123-123
154-154: LGTM! Headers properly constructed and passed for issue ingestion.The headers are built using the shared
buildAiGatewayHeadersfunction with the team context and correctly passed to theingestGitHubIssuesfunction.Also applies to: 162-162
apps/studio.giselles.ai/lib/vector-stores/github/ingest/pull-requests/ingest-github-pull-requests.ts (1)
29-29: LGTM! Headers parameter properly propagated.The optional
headersparameter is correctly added to the function signature and properly propagated to the ingestion pipeline, consistent with the pattern used in blob and issue ingestion.Also applies to: 63-63
apps/studio.giselles.ai/lib/vector-stores/github/ingest/blobs/ingest-github-blobs.ts (1)
27-27: LGTM! Headers parameter properly propagated.The optional
headersparameter is correctly added to the function signature and properly propagated to the ingestion pipeline, consistent with the pattern used in pull request and issue ingestion.Also applies to: 59-59
apps/studio.giselles.ai/lib/vector-stores/shared/ai-gateway-headers.ts
Outdated
Show resolved
Hide resolved
| const stripeCustomerId = team?.activeCustomerId ?? undefined; | ||
| if (stripeCustomerId !== undefined) { | ||
| headers["stripe-customer-id"] = stripeCustomerId; | ||
| headers["stripe-restricted-access-key"] = | ||
| process.env.STRIPE_AI_GATEWAY_RESTRICTED_ACCESS_KEY ?? ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty string fallback for restricted access key may cause silent failures.
Line 21 falls back to an empty string when STRIPE_AI_GATEWAY_RESTRICTED_ACCESS_KEY is not set. This could lead to authentication failures that are difficult to debug. Consider either requiring the environment variable when a customer ID is present, or logging a warning about the missing key.
Apply this diff to add a warning:
const stripeCustomerId = team?.activeCustomerId ?? undefined;
if (stripeCustomerId !== undefined) {
+ const restrictedAccessKey = process.env.STRIPE_AI_GATEWAY_RESTRICTED_ACCESS_KEY;
+ if (!restrictedAccessKey) {
+ console.warn(
+ `STRIPE_AI_GATEWAY_RESTRICTED_ACCESS_KEY not set for team with customer ID (team: ${team?.id})`,
+ );
+ }
headers["stripe-customer-id"] = stripeCustomerId;
- headers["stripe-restricted-access-key"] =
- process.env.STRIPE_AI_GATEWAY_RESTRICTED_ACCESS_KEY ?? "";
+ headers["stripe-restricted-access-key"] = restrictedAccessKey ?? "";
} else if (team?.plan === "pro" || team?.plan === "team") {🤖 Prompt for AI Agents
In apps/studio.giselles.ai/lib/vector-stores/shared/ai-gateway-headers.ts around
lines 17 to 21, the code falls back to an empty string for
STRIPE_AI_GATEWAY_RESTRICTED_ACCESS_KEY which can cause silent auth failures;
when stripeCustomerId exists, check
process.env.STRIPE_AI_GATEWAY_RESTRICTED_ACCESS_KEY and if it's missing, either
throw or at minimum log a clear warning including team/stripeCustomerId context,
and only set headers["stripe-restricted-access-key"] when a non-empty env value
exists (do not leave an empty string in the header).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Fetch details of the issue #2338
gh issue view 2338 --repo giselles-ai/giselle --json number,title,body,author,state,url
Length of output: 2376
@shige, thanks for creating issue #2338 to track this! 👍 The follow-up will ensure the missing STRIPE_AI_GATEWAY_RESTRICTED_ACCESS_KEY is properly handled with appropriate warnings.
🧠 Learnings used
Learnt from: shige
Repo: giselles-ai/giselle PR: 2290
File: apps/studio.giselles.ai/db/schema.ts:109-169
Timestamp: 2025-11-28T00:51:04.041Z
Learning: The team is consciously using Stripe API version 2025-11-17.preview for Stripe v2 billing cadence (stripeBillingCadenceHistories) and pricing plan subscription (stripePricingPlanSubscriptionHistories) features in apps/studio.giselles.ai/db/schema.ts with awareness that preview APIs may not be production-safe.
🔍 QA Testing Assistant by Giselle📋 Manual QA ChecklistBased on the changes in this PR, here are the key areas to test manually:
✨ Prompt for AI AgentsUse the following prompts with Cursor or Claude Code to automate E2E testing: 📝 E2E Test Generation Prompt |
Create a shared utility function in vector-stores/shared/ to build AI Gateway headers with Stripe customer ID for billing attribution.
Replace local buildAiGatewayHeaders implementation with the shared utility function for consistency across vector store ingestion flows.
- Add headers parameter to RAG ingest pipeline options - Pass headers through GitHub blob, PR, and issue ingest functions - Call buildAiGatewayHeaders in processRepository This ensures AI Gateway requests during GitHub repository ingestion include Stripe customer ID for billing attribution.
The function always returns a headers object, never undefined. Remove `| undefined` from the return type for accuracy.
56c08a4 to
baed4dd
Compare
|
Thank you! 🚀 |
User description
Summary
buildAiGatewayHeadersfunction invector-stores/shared/for consistent header constructionheadersparameter to RAG ingest pipeline optionsbuildAiGatewayHeadersfunctionThis ensures AI Gateway requests during GitHub repository ingestion include Stripe customer ID for billing attribution, completing the header propagation across all vector store ingest flows.
Related Issue
Part of #2233
Testing
#2289 (comment)
PR Type
Enhancement
Description
Create shared
buildAiGatewayHeadersutility function for consistent header construction across vector store ingestion flowsAdd
headersparameter to RAG ingest pipeline options for AI Gateway request propagationPass stripe-customer-id headers through GitHub blob, PR, and issue ingest functions
Refactor document ingest to use shared utility function, improving code reusability and maintainability
Diagram Walkthrough
File Walkthrough
ai-gateway-headers.ts
Create shared AI Gateway headers utility functionapps/studio.giselles.ai/lib/vector-stores/shared/ai-gateway-headers.ts
buildAiGatewayHeadersfor building AIGateway headers with Stripe customer ID
document ingest
stripe-restricted-access-key headers
process-repository.ts
Add header generation to GitHub content processorsapps/studio.giselles.ai/lib/vector-stores/github/ingest/process-repository.ts
buildAiGatewayHeadersfunctionbuildAiGatewayHeadersin blob, PR, and issue content processorsattribution
ingest-github-blobs.ts
Add headers parameter to blob ingest functionapps/studio.giselles.ai/lib/vector-stores/github/ingest/blobs/ingest-github-blobs.ts
headersparameter to function signatureingest-github-pull-requests.ts
Add headers parameter to PR ingest functionapps/studio.giselles.ai/lib/vector-stores/github/ingest/pull-requests/ingest-github-pull-requests.ts
headersparameter to function signatureingest-github-issues.ts
Add headers parameter to issue ingest functionapps/studio.giselles.ai/lib/vector-stores/github/ingest/issues/ingest-github-issues.ts
headersparameter to function signaturepipeline.ts
Add headers support to RAG ingest pipelinepackages/rag/src/ingest/pipeline.ts
headersproperty toIngestPipelineOptionsinterfaceingest-document.ts
Refactor document ingest to use shared headers utilityapps/studio.giselles.ai/lib/vector-stores/document/ingest/ingest-document.ts
buildAiGatewayHeadersfunction implementationbuildAiGatewayHeadersfrom vector-stores/sharedteamobject instead oftelemetryContextcode
Summary by CodeRabbit
Refactor
New Features
✏️ Tip: You can customize this high-level summary in your review settings.
Note
Introduces a shared header builder and threads Stripe billing headers through document, GitHub, and RAG ingest paths to AI Gateway.
buildAiGatewayHeadersinvector-stores/sharedfor billing attribution (Stripe headers, referer/title; warns when missing ID).buildAiGatewayHeaders(team)and passheaderstogenerateEmbeddings.headerstoingestGitHubBlobs,ingestGitHubPullRequests,ingestGitHubIssues; construct viabuildAiGatewayHeaders(team)inprocess-repositoryand pass through to pipelines.IngestPipelineOptionswithheaders; forward to embedder when using gateway transport.Written by Cursor Bugbot for commit baed4dd. This will update automatically on new commits. Configure here.