@@ -263,12 +263,35 @@ func resourceOpenAIVectorStoreFileCreate(ctx context.Context, d *schema.Resource
263263 }
264264 }
265265
266- // Wait for the file to be available in the vector store with retry logic
266+ // Wait for the file to be available in the vector store with retry logic.
267+ // This addresses eventual consistency issues where the OpenAI API returns
268+ // "No file found" errors immediately after file creation (issue #35).
267269 return resourceOpenAIVectorStoreFileReadWithRetry (ctx , d , m , 5 )
268270}
269271
270272// resourceOpenAIVectorStoreFileReadWithRetry attempts to read the vector store file with retry logic
271- // to handle eventual consistency issues with the OpenAI API
273+ // to handle eventual consistency issues with the OpenAI API.
274+ //
275+ // When a vector store file is created, the OpenAI API may temporarily return "file not found"
276+ // errors due to eventual consistency delays in their backend. This is especially common when
277+ // creating multiple files simultaneously.
278+ //
279+ // Retry Behavior:
280+ // - Retries up to maxRetries times (default: 5)
281+ // - Uses exponential backoff: 1s, 2s, 4s, 8s, 16s (max ~31s total)
282+ // - Only retries on "not found" errors (case-insensitive)
283+ // - Returns immediately on other errors (unauthorized, rate limit, etc.)
284+ // - Logs retry attempts for debugging
285+ //
286+ // Parameters:
287+ // - ctx: Context for logging
288+ // - d: Resource data
289+ // - m: Provider metadata containing OpenAI client
290+ // - maxRetries: Maximum number of read attempts (must be >= 1)
291+ //
292+ // Returns:
293+ // - nil diagnostics on success
294+ // - diagnostics with error details if all retries are exhausted or non-retriable error occurs
272295func resourceOpenAIVectorStoreFileReadWithRetry (ctx context.Context , d * schema.ResourceData , m interface {}, maxRetries int ) diag.Diagnostics {
273296 var lastErr diag.Diagnostics
274297
0 commit comments