Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Standalone CI for the public ClickHouse/code-interpreter repo, which is
# Standalone CI for the public LibreChat-AI/code-interpreter repo, which is
# published from services/codeapi as snapshot commits (see
# .github/workflows/publish-codeapi.yml in the monorepo). This file is
# inert inside the monorepo — GitHub only runs workflows from the repo
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/open-sync-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
run: |
OPEN=$(gh api -X GET repos/ClickHouse/code-interpreter/pulls \
-f state=open -f base=main -f head=ClickHouse:sync/main \
OPEN=$(gh api -X GET "repos/${GITHUB_REPOSITORY}/pulls" \
-f state=open -f base=main -f head="${GITHUB_REPOSITORY_OWNER}:sync/main" \
-f per_page=1 --jq length)
if [ "$OPEN" -gt 0 ]; then
echo "Sync PR already open."
Expand Down
37 changes: 37 additions & 0 deletions api/src/api/v2-session-binding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,43 @@ describe('per-request session binding', () => {
}
});

test('a nameless utf8 inline source uses the default filename and remains runnable', async () => {
config.session_workspace_enabled = false;
config.require_execution_manifest = false;

const originalPrime = Job.prototype.prime;
const originalExecute = Job.prototype.execute;
const originalCleanup = Job.prototype.cleanup;

let primedName: string | undefined;
Job.prototype.prime = async function trackDefaultName(): Promise<void> {
primedName = this.files[0]?.name;
};
Job.prototype.execute = async function executeWithoutSandbox() {
return {} as Awaited<ReturnType<Job['execute']>>;
};
Job.prototype.cleanup = async function cleanupWithoutFilesystem(): Promise<void> {};

try {
const response = await fetch(`${baseUrl}/api/v2/execute`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
language: testLanguage,
version: testVersion,
files: [{ content: 'test' }],
}),
});

expect(response.status).toBe(200);
expect(primedName).toBe('file0.code');
} finally {
Job.prototype.prime = originalPrime;
Job.prototype.execute = originalExecute;
Job.prototype.cleanup = originalCleanup;
}
});

test('a post-prime failure still reports the workspace as dirty', async () => {
config.session_workspace_enabled = true;
config.require_execution_manifest = false;
Expand Down
7 changes: 5 additions & 2 deletions api/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ export function isDirkeep(name: string): boolean {
* execute — leaving the rejected request's writes behind.
*/
export function hasRunnableSource(
files: Array<{ name: string; encoding?: string }>,
files: Array<{ name?: string; encoding?: string }>,
language: string,
): boolean {
if (language === 'file') return true;
return files.some(
(file) => !isDirkeep(file.name) && (!file.encoding || file.encoding === 'utf8'),
/* Request files may omit `name`; Job normalizes those to `file${i}.code`,
* which is runnable and cannot be the .dirkeep sentinel. */
(file) => (file.name === undefined || !isDirkeep(file.name))
&& (!file.encoding || file.encoding === 'utf8'),
);
}

Expand Down