You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
• Add AI opt-in flags and row limits on the database resource.
• Add per-credential AI permission and optional query timeout support.
• Update docs, examples, and acceptance tests to cover new attributes.
Diagram
graph TD
A["Terraform config"] --> B["Database resource"] --> C["Provider model+schema"] --> D["DevHub client models"] --> E["DevHub API"]
F["Docs + examples"] --> A
G["Acceptance tests"] --> B
subgraph Legend
direction LR
_cfg["Config / HCL"] ~~~ _prov["Provider component"] ~~~ _api["External API"]
end
Loading
High-Level Assessment
The following are alternative approaches to this PR:
1. Model timeout as duration string (e.g., "30s")
➕ More idiomatic for Terraform users (aligns with time.ParseDuration style).
➕ Avoids ambiguity around units (seconds vs milliseconds).
➖ Requires parsing/validation and potential API conversion logic.
➖ Could be a breaking change if the API/clients expect numeric seconds.
Recommendation: Current approach (int seconds for timeout, bool flags for AI access) is reasonable and matches the apparent API contract. If users frequently need sub-second or explicit units, consider a future enhancement to accept duration strings while still storing seconds in the API model.
Files changed (5) +104 / -16
Enhancement (2) +61 / -0
models.goAdd AI fields to API models+4/-0
Add AI fields to API models
• Extends Database and DatabaseCredential client structs with ai_enabled/ai_max_rows and ai_allowed/timeout JSON fields so requests/responses can carry AI settings.
devhub_querydesk_database_resource.goExpose AI attributes in schema and map to API+57/-0
Expose AI attributes in schema and map to API
• Adds new Terraform schema attributes (ai_enabled, ai_max_rows, ai_allowed, timeout) with defaults for database-level AI settings, maps them into API create/update payloads, and reads them back into state including nil-safe timeout handling.
devhub_querydesk_database_resource_test.goAdd acceptance coverage for AI fields+23/-8
Add acceptance coverage for AI fields
• Updates the acceptance test config helper to parameterize AI settings and adds assertions for ai_enabled/ai_max_rows, credential ai_allowed, and presence/absence of credential timeout across create and update steps.
querydesk_database.mdDocument AI database and credential fields+12/-4
Document AI database and credential fields
• Updates the resource docs to include ai_enabled/ai_max_rows on the database and ai_allowed/timeout on credentials, and extends the example snippet accordingly.
• Updates the example resource configuration to demonstrate enabling AI, setting a max row limit, allowing AI on a credential, and setting a credential timeout.
1. Update ignores API response✓ Resolved🐞 Bug☼ Reliability
Description
In databaseResource.Update, the provider sends ai_enabled/ai_max_rows and per-credential
ai_allowed/timeout to the API but then writes state from the plan and only backfills credential IDs,
discarding any server-canonicalized values for these fields.
Update() includes the new AI fields in the API request payload, but after receiving database from
UpdateDatabase, it only copies credential IDs and then sets state from plan, unlike Read() which
maps all fields (including AI fields and timeout) from the server response into state.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
### Issue description
`databaseResource.Update` calls `UpdateDatabase(...)` and receives an updated `database` object, but it only uses it to backfill credential IDs and then persists `plan` into state. This can immediately lose server-returned/canonical values for new AI fields (`ai_enabled`, `ai_max_rows`, `credentials[*].ai_allowed`, `credentials[*].timeout`) as well as other computed credential fields.
### Issue Context
The `Read` method already contains the mapping logic from `devhub.Database` -> `databaseResourceModel`. After `UpdateDatabase`, state should be hydrated from the returned `database` (or `Read` should be invoked) to ensure Terraform state reflects the server.
### Fix Focus Areas
- internal/provider/devhub_querydesk_database_resource.go[431-475]
- internal/provider/devhub_querydesk_database_resource.go[328-386]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
2. Timeout not saved on create✓ Resolved🐞 Bug≡ Correctness
Description
In databaseResource.Create, the provider hydrates state from the API response for some credential
fields (id/default_credential/ai_allowed) but never copies back the API-returned timeout, so state
is written with the planned timeout even if the server returns a different value.
for index, credential := range database.Credentials {
plan.Credentials[index].Id = types.StringValue(credential.Id)
plan.Credentials[index].DefaultCredential = types.BoolValue(credential.DefaultCredential)
+ plan.Credentials[index].AiAllowed = types.BoolValue(credential.AiAllowed)
Evidence
Create() sets state from the plan after selectively copying some credential fields from the API
response, but it never maps the returned Timeout; Read() explicitly maps Timeout from the API
response into state, demonstrating that Timeout is intended to be persisted from the server
representation.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
### Issue description
`databaseResource.Create` updates `plan.Credentials[index]` from the `database.Credentials` API response, but it does not set `plan.Credentials[index].Timeout`. Since the function then writes state from `plan`, the credential timeout in state can diverge from the server's returned value.
### Issue Context
The `Read` path already contains the correct mapping logic for `credential.Timeout` -> `types.Int64Null()/types.Int64Value(...)`, which can be reused.
### Fix Focus Areas
- internal/provider/devhub_querydesk_database_resource.go[286-292]
- internal/provider/devhub_querydesk_database_resource.go[364-382]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.