Skip to content

feat(api): support project API key scope updates - #4082

Open
jbeckwith-oai wants to merge 1 commit into
mainfrom
castiron/promotions/pr-251
Open

jbeckwith-oai wants to merge 1 commit into
mainfrom
castiron/promotions/pr-251

Conversation

@jbeckwith-oai

Copy link
Copy Markdown
Contributor

Summary

Update scope restrictions on an existing project API key, alone or together with its expiration.

Changes

  • Add optional scopes to project API key updates.
  • Make expires_in_seconds optional for scope-only updates.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Castiron custom code

Evaluated main: 70d473892f7c427a02a3b566add9c86072842e25.

✅ No new custom-code files detected.

40 mixed files remain; 0 existing customizations changed.

Compared 70d473892f7c → 114246f5d341. Generated baselines verified.

40 existing customizations unchanged
  • api.md
  • scripts/castiron/custom_code_budget.py
  • scripts/castiron/test_custom_code_github.py
  • scripts/castiron/test_custom_code_publication.py
  • scripts/castiron/test_custom_code_report.py
  • src/openai/init.py
  • src/openai/_client.py
  • src/openai/resources/audio/transcriptions.py
  • src/openai/resources/audio/translations.py
  • src/openai/resources/beta/agents/environments/files.py
  • src/openai/resources/beta/agents/sessions/artifacts.py
  • src/openai/resources/beta/agents/sessions/sessions.py
  • src/openai/resources/beta/beta.py
  • src/openai/resources/beta/responses/responses.py
  • src/openai/resources/beta/threads/runs/runs.py
  • src/openai/resources/beta/threads/threads.py
  • src/openai/resources/chat/completions/completions.py
  • src/openai/resources/embeddings.py
  • src/openai/resources/files.py
  • src/openai/resources/live/forks.py
  • src/openai/resources/live/live.py
  • src/openai/resources/live/sideband.py
  • src/openai/resources/realtime/api.md
  • src/openai/resources/realtime/realtime.py
  • src/openai/resources/responses/responses.py
  • src/openai/resources/uploads/uploads.py
  • src/openai/resources/vector_stores/file_batches.py
  • src/openai/resources/vector_stores/files.py
  • src/openai/resources/videos.py
  • src/openai/resources/webhooks/init.py
  • src/openai/resources/webhooks/webhooks.py
  • src/openai/types/fine_tuning/fine_tuning_job_integration.py
  • src/openai/types/realtime/conversation_item_input_audio_transcription_delta_event.py
  • src/openai/types/realtime/realtime_error_event.py
  • src/openai/types/responses/tool.py
  • src/openai/types/responses/tool_param.py
  • src/openai/types/webhooks/init.py
  • src/openai/types/webhooks/live_call_incoming_webhook_event.py
  • src/openai/types/webhooks/unwrap_webhook_event.py
  • tests/api_resources/test_videos.py

A changed generated baseline means this report cannot reliably identify which handwritten lines changed.

Inspect the custom-code diff

Download the exact patch produced by this run (requires repository access):

gh run download 38685136778 --repo openai/openai-python \
  --name castiron-custom-code-38685136778-1 --dir /tmp/castiron-custom-code-38685136778-1
git apply --stat /tmp/castiron-custom-code-38685136778-1/custom-code.patch
cat /tmp/castiron-custom-code-38685136778-1/custom-code.patch

Or reproduce it from an SDK checkout containing the vendored reporter:

git fetch --no-tags origin 70d473892f7c427a02a3b566add9c86072842e25 114246f5d3413e88d6277b57105b80c6e4f75e7c
python3 scripts/castiron/custom_code_report.py report \
  --base 70d473892f7c427a02a3b566add9c86072842e25 \
  --head 114246f5d3413e88d6277b57105b80c6e4f75e7c --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-114246f5d341
cat /tmp/castiron-custom-code-114246f5d341/custom-code.patch

This is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR.

Full report and patch

@jbeckwith-oai
jbeckwith-oai requested a review from a team October 14, 2026 22:38

@markstuart-oai markstuart-oai left a comment

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.

Reviewed f05bdb4.

The sync and async update paths preserve omitted expiration, explicit empty scopes, existing expiry-only calls, and admin authentication. The generated request type and docs match the shared API contract. No blocking findings.

Validation: immutable source review and current-head hosted CI; all reported native checks passed or were skipped. I did not run local tests.

@jbeckwith-oai
jbeckwith-oai force-pushed the castiron/promotions/pr-251 branch from f05bdb4 to 71e0ff1 Compare October 15, 2026 01:20
@jbeckwith-oai
jbeckwith-oai marked this pull request as ready for review October 15, 2026 04:31
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T05:09:18.387562Z 114246f New commits
🔒 Security Review ✅ Completed 2026-10-15T05:10:26.373908Z 114246f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openai-sdks

openai-sdks Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

OkTest Summary

✅ 236/236 SDK tests passed in 7.725s for Python SDK PR #4082.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 172ms
tests/chat-completions-create.test.ts ✅ Passed 159ms
tests/chat-completions-stream.test.ts ✅ Passed 194ms
tests/files-content-binary.test.ts ✅ Passed 148ms
tests/files-create-multipart.test.ts ✅ Passed 225ms
tests/files-list-pagination.test.ts ✅ Passed 108ms
tests/initialize-config.test.ts ✅ Passed 149ms
tests/instance-isolation.test.ts ✅ Passed 128ms
tests/models-list.test.ts ✅ Passed 140ms
tests/responses-background-lifecycle.test.ts ✅ Passed 142ms
tests/responses-body-method-errors.test.ts ✅ Passed 224ms
tests/responses-cancel-timeout.test.ts ✅ Passed 187ms
tests/responses-cancel.test.ts ✅ Passed 134ms
tests/responses-compact-retries.test.ts ✅ Passed 213ms
tests/responses-compact.test.ts ✅ Passed 164ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 204ms
tests/responses-create-advanced.test.ts ✅ Passed 151ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.204s
tests/responses-create-errors.test.ts ✅ Passed 164ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 302ms
tests/responses-create-retries.test.ts ✅ Passed 184ms
tests/responses-create-stream-failures.test.ts ✅ Passed 492ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 212ms
tests/responses-create-stream-wire.test.ts ✅ Passed 1.8s
tests/responses-create-stream.test.ts ✅ Passed 125ms
tests/responses-create-terminal-states.test.ts ✅ Passed 178ms
tests/responses-create-timeout.test.ts ✅ Passed 200ms
tests/responses-create.test.ts ✅ Passed 446ms
tests/responses-delete.test.ts ✅ Passed 149ms
tests/responses-input-items-errors.test.ts ✅ Passed 292ms
tests/responses-input-items-list.test.ts ✅ Passed 232ms
tests/responses-input-items-options.test.ts ✅ Passed 215ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 236ms
tests/responses-input-tokens-count.test.ts ✅ Passed 212ms
tests/responses-malformed-inputs.test.ts ✅ Passed 831ms
tests/responses-not-found-errors.test.ts ✅ Passed 221ms
tests/responses-parse.test.ts ✅ Passed 201ms
tests/responses-retrieve-retries.test.ts ✅ Passed 230ms
tests/responses-retrieve.test.ts ✅ Passed 146ms
tests/responses-stored-method-errors.test.ts ✅ Passed 362ms
tests/retry-behavior.test.ts ✅ Passed 3.061s
tests/sdk-error-shape.test.ts ✅ Passed 208ms

View OkTest run #38685094657

SDK merge (e4a0d46b5a21) · head (114246f5d341) · base (70d473892f7c) · OkTest (63b471b22245)

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71e0ff1ae0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

type: object
required:
- expires_in_seconds
required: []

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Enforce a non-empty API-key update

With both properties optional and no object-level constraint, this schema accepts {}, so the generated clients expose update(api_key_id=..., project_id=...) and the new tests incorrectly treat that request as successful. This contradicts the endpoint contract that at least one of scopes or expires_in_seconds must be supplied and causes such calls to send an invalid no-op request that the real API rejects; encode the at-least-one constraint or validate it in both client methods.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed: this SDK currently permits an update with neither field and dispatches a request that the server rejects. The generated mock test does not establish that the real API accepts an empty update. The CLI's local guard does not fix this SDK.

The at-least-one schema/compiler constraint remains deferred while we preserve existing public request types. The smallest proposed behavioral correction is an endpoint-specific check of the effective request body before dispatch, with tests for an empty request and the valid expiry-only, scope-only, combined, and empty-scope-list cases. That proposal must also preserve supported request-body overrides; checking only named arguments would be insufficient.

No correction has been made to this SDK yet. Leaving this finding open and holding this PR from the merge queue pending agreement on that additional runtime validation versus an explicitly accepted server-validation disposition.

Castiron-Internal-PR: openai/openai-python-internal#251
Castiron-Source-SHA: 683a160c9996b947916850f11bf258c613fc9f51
Castiron-Public-Base-SHA: 70d4738
@jbeckwith-oai
jbeckwith-oai force-pushed the castiron/promotions/pr-251 branch from 71e0ff1 to 114246f Compare October 15, 2026 05:07
@jbeckwith-oai

Copy link
Copy Markdown
Contributor Author

Updated the baseline in 114246f. The PR base now matches main, and the fresh OkTest run has passed preparation and reached the SDK tests: https://github.com/openai/ok-test/actions/runs/38685094657 . This addresses the stale merge-parent preparation problem; the full test run is still in progress.

The empty-update review finding is separate and remains unresolved. This baseline refresh does not add a schema constraint or client-side validation, and this PR remains out of the merge queue pending that decision. Review has been re-requested for the updated commit.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants