OpenAI usage tracking: Project ID setting is ignored
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 35/100
Direzione di ricerca
Read includes/Classifai/Providers/ProviderProfiles.php and trace CredentialResolver::resolve() for the api_usage_tracking profile; the issue names the affected fields and request path. Check the existing credential resolver and UsageTrackingProvider tests, then verify that configured project IDs appear as project_ids on costs requests and are omitted when unset. A linked pull request is already open.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
The AI Usage Tracking feature lets you enter an optional Project ID so cost data is restricted to a single OpenAI project (see wp-hooks-docs/docs/02.feature-configuration/19.usage-tracking.md: "Optionally enter a Project ID to restrict cost data to a single OpenAI project."). The value is saved, but it never reaches the OpenAI costs request, so the usage and cost totals are always organization-wide.
Steps to reproduce
- Enable ClassifAI → Usage Tracking → AI Usage Tracking and select OpenAI.
- Enter an Admin API key and a Project ID (e.g.
proj_abc123), then save the settings. - Trigger a usage refresh (wait for the Action Scheduler run or click Refresh Usage Data).
- Inspect the request to
https://api.openai.com/v1/organization/costs: there is noproject_idsquery arg, so the totals include every project in the organization.
Expected behavior
The saved Project ID should be sent as the project_ids query arg on the costs request, which is what UsageTrackingProvider::fetch_period() attempts to do.
Root cause
UsageTrackingProvider::fetch_period() reads the setting with get_credential( 'project_id', $settings ). That call goes through Provider::get_credentials() → CredentialResolver::resolve(), which keeps only the fields listed in the provider profile's credential_fields. The api_usage_tracking profile in includes/Classifai/Providers/ProviderProfiles.php lists only api_key and authenticated, so project_id is filtered out and $project_id is always empty. That makes the if ( ! empty( $project_id ) ) { $url = add_query_arg( 'project_ids', $project_id, $url ); } branch unreachable.
This is the same pattern the Azure profiles already use: the non-secret deployment value is listed next to the credentials so it survives resolution.
Proposed fix
Add project_id to the api_usage_tracking profile's credential_fields (it stays out of sensitive_fields, so it is not obfuscated) and add regression tests that cover:
CredentialResolver::resolve( 'openai_usage_tracking', ... )keepsproject_id;fetch_period()requests includeproject_ids=<value>when a Project ID is configured, and omit it when not.
A PR covering this will follow.
- Lingua principale
- PHP
- Stelle
- 714
- Fork
- 68
- Merge medio
- 4h 32m
- PR unite (30g)
- 23
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di 10up/classifai
-
wpvc
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
wpvc
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Register ClassifAI functionality with the Abilities APIForse già presa @nhrrob l’ha presa 10 giorni fa. Apertahelp wanted
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
10up/classifai#1249 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
BYOK Openai modelsAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
help wanted
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
10up/classifai#1207 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di 10up/classifai
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
firefly-iii/firefly-iii#13259 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[Sync EN] Document the getLastErrors() return value change in the PHP 8.2 migration guide (#6107)Apertasync-en
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
sync-en
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Перевод устарел
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno