← 输入框|github.com|刷新
Skip to content

[connectors] Report "no Samply profile" as 204, not as an error - #7934

Open
blp wants to merge 1 commit into
mainfrom
samply-no-profile-status
Open

blp wants to merge 1 commit into
mainfrom
samply-no-profile-status

Conversation

@blp

@blp blp commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

When the Samply tab opens, the web console checks for a profile with GET /samply_profile?latest=true. Before any profile exists, the pipeline answered 400 NoSamplyProfile. In feldera/cloud#2163 those 400s in the browser network log sent the support bundle investigation the wrong way.

Request Before After
?latest=true, profile in progress 204 + Retry-After same
?latest=true, no profile 400 NoSamplyProfile 204, no Retry-After
no latest, no profile 400 NoSamplyProfile same
  • The web console reads a 204 without Retry-After as "no profile".
  • The API docs said 307 for a profile in progress. The code sends 204, so the docs now say 204.
  • Changelog entry added, because this is an API change.

Multihost needs feldera/cloud#2207: the coordinator read a host's 204 as an empty profile.

Tests

  • New samply_profile_latest_without_profile engine test. It fails (400 instead of 204) with the fix disabled.
  • svelte-check: 0 errors. Prettier: clean.

-- Claude Code, at @blp's request.

When the Samply tab opens, the web console checks for a profile with
`GET /samply_profile?latest=true`. Before any profile, the pipeline
answered 400 `NoSamplyProfile`, so each check put an error in the
browser's network log. In feldera/cloud#2163, these errors sent an
investigation of a failed support bundle the wrong way.

With `latest=true`, a 204 No Content now means that there is no profile
to download yet: with `Retry-After` if one is in progress, as before,
and without it if none was started. Without `latest`, nothing changes.

Also corrects the API docs, which said 307 for a profile in progress.

Signed-off-by: Ben Pfaff <blp@feldera.com>
@blp blp added bug Something isn't working Web Console Related to the browser based UI API Distributed system APIs connectors Issues related to the adapters/connectors crate profiler Issues related to the profiler and its APIs labels Nov 11, 2026
@blp blp self-assigned this Nov 11, 2026
const expectedInSeconds = parseInt(response.headers.get('Retry-After') ?? '')
const retryAfter = response.headers.get('Retry-After')
if (retryAfter === null) {
return null

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.

missing (medium): this new 204 branch is the client half of the contract, and no test covers it. The Rust test only checks the server. Here is a unit test I ran locally with vitest --project server (5/5 pass). It could go in as src/lib/services/samplyProfile.spec.ts:

import { afterEach, describe, expect, it, vi } from 'vitest'
import { getSamplyProfile } from '#lib/services/pipelineManager.ts'

const stubFetch = (response: Response) =>
  vi.stubGlobal('fetch', Object.assign(vi.fn().mockResolvedValue(response), { preconnect: () => {} }))

describe('getSamplyProfile', () => {
  afterEach(() => vi.unstubAllGlobals())

  it('returns null on 204 without Retry-After', async () => {
    stubFetch(new Response(null, { status: 204 }))
    expect(await getSamplyProfile('p', true)).toBeNull()
  })
  it('returns expectedInSeconds on 204 with Retry-After', async () => {
    stubFetch(new Response(null, { status: 204, headers: { 'Retry-After': '7' } }))
    expect(await getSamplyProfile('p', true)).toEqual({ expectedInSeconds: 7 })
  })
  it('returns expectedInSeconds 0 on 204 with Retry-After: 0', async () => {
    stubFetch(new Response(null, { status: 204, headers: { 'Retry-After': '0' } }))
    expect(await getSamplyProfile('p', true)).toEqual({ expectedInSeconds: 0 })
  })
  it('throws on 204 with a malformed Retry-After', async () => {
    stubFetch(new Response(null, { status: 204, headers: { 'Retry-After': 'soon' } }))
    await expect(getSamplyProfile('p', true)).rejects.toThrow(/estimated time is not known/)
  })
  it('returns a download handle on 200', async () => {
    stubFetch(new Response(new Uint8Array([1, 2, 3]), { status: 200, headers: {
      'Content-Type': 'application/gzip', 'Content-Disposition': 'attachment; filename="p.json.gz"' } }))
    const result = await getSamplyProfile('p', true)
    expect(result && 'downloadPromise' in result).toBe(true)
  })
})

@mythical-fred-oss

Copy link
Copy Markdown
Contributor

What I ran

Check Result
cargo test -p static-connectors --test connector_suites -- samply_profile (runs the #[engine_test] cases) ✅ 2/2, including the new samply_profile_latest_without_profile
pre-commit run on the changed files (clippy, fmt, OpenAPI/client regen, JS check) ✅
New vitest spec for getSamplyProfile's 204 handling (see inline) ✅ 5/5

Gates: the server change has a test, the changelog marks the incompatible change, and the API docs are fixed in the Rust source. I found no flaky tests, unsafe code or dependency changes.

  • pitfall (medium): merge order for multihost. As the description says, a multihost coordinator that gets a host's 204 without Retry-After treats it as an empty profile. Land the coordinator fix first, or together with this one, so no release ships one without the other.
  • missing (medium): no test covers the web console's new null path. A test for it is in the inline comment.
  • missing (low, existing gap): no test covers latest=true with a profile in progress (204 + Retry-After) or with a stored profile/error (200/500). Both need a samply run, so a follow-up is fine.

Otherwise LGTM.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API Distributed system APIs bug Something isn't working connectors Issues related to the adapters/connectors crate profiler Issues related to the profiler and its APIs Web Console Related to the browser based UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants