Skip to content

feat(gooddata-sdk): [AUTO] Add UserContext, DashboardContext, UIContext, RichTextWidgetDescriptor#1577

Open
yenkins-admin wants to merge 1 commit intomasterfrom
auto/openapi-sync-C015-20260420-r82171
Open

feat(gooddata-sdk): [AUTO] Add UserContext, DashboardContext, UIContext, RichTextWidgetDescriptor#1577
yenkins-admin wants to merge 1 commit intomasterfrom
auto/openapi-sync-C015-20260420-r82171

Conversation

@yenkins-admin
Copy link
Copy Markdown
Contributor

Summary

Added SDK wrapper classes for UserContext, DashboardContext, UIContext, RichTextWidgetDescriptor and supporting types in a new compute/model/chat_context.py module. Updated ai_chat() and ai_chat_stream() in ComputeService to accept an optional user_context: CatalogUserContext keyword-only parameter. Exported all new public classes from gooddata_sdk/init.py. Added unit tests covering model construction and as_api_model() serialization.

Impact: new_feature | Services: gooddata-afm-client, gooddata-automation-client
Tickets: LX-2168, LX-2199

Files changed

  • packages/gooddata-sdk/src/gooddata_sdk/compute/model/chat_context.py
  • packages/gooddata-sdk/src/gooddata_sdk/compute/service.py
  • packages/gooddata-sdk/src/gooddata_sdk/__init__.py
  • packages/gooddata-sdk/tests/compute/test_chat_context.py

Agent decisions

Decisions (4)

placement of context wrapper classes — New file compute/model/chat_context.py

  • Alternatives: catalog/workspace/entity_model/ — conflates workspace catalog entities with compute-side request models, catalog/organization/entity_model/ — wrong domain; these are workspace-scoped request inputs
  • Why: Context models are exclusively used by the AI chat endpoint in compute/service.py; co-locating them under compute/model/ keeps the layer coherent.

filter field type in WidgetDescriptor / RichTextWidgetDescriptor — list[dict[str, Any]] for filters

  • Alternatives: Create typed FilterDefinition wrapper classes — correct but over-engineered for an optional field
  • Why: FilterDefinition is a ModelComposed type with ~10 subtypes; full wrapping adds major complexity for an optional passthrough field.

keyword-only user_context parameter — Keyword-only via * separator, default None

  • Alternatives: Positional parameter — breaking change for existing callers
  • Why: Backward-compatible: positional callers of ai_chat(workspace_id, question) are unaffected.

explicit as_api_model() vs Base.to_api() — Explicit as_api_model() for models with nested SDK objects; Base.to_api() for leaf models

  • Alternatives: Rely entirely on Base.to_api() — simpler but risks silent failures in deep-nested from_dict
  • Why: Deep-nested attrs.asdict() + client_class().from_dict() chains are fragile; explicit methods give full serialization control.
Assumptions to verify (3)
  • The generated gooddata-api-client already includes the updated UserContext/DashboardContext/UIContext/RichTextWidgetDescriptor with their AFM-service shape (activeObject/referencedObjects/view, not the simpler userId/userEmail from the diff).
  • ChatRequest.user_context accepts the AFM-service UserContext shape.
  • The diff's simpler context shapes (userId/userEmail, timezone, dashboardId) may represent fields from gooddata-automation-client that haven't been separately generated in this repo.
Risks (2)
  • If the API server expects the simpler UserContext shape (userId/userEmail) instead of the richer AFM shape, CatalogUserContext.as_api_model() will send wrong payload.
  • CatalogDashboardContext.widgets only accepts CatalogWidgetDescriptor; callers passing CatalogRichTextWidgetDescriptor need a Union alias — may need follow-up.
Layers touched (3)
  • entity_model — New SDK wrapper classes for AI chat context models
    • packages/gooddata-sdk/src/gooddata_sdk/compute/model/chat_context.py
  • public_api — Exported new classes; added user_context param to ai_chat and ai_chat_stream
    • packages/gooddata-sdk/src/gooddata_sdk/__init__.py
    • packages/gooddata-sdk/src/gooddata_sdk/compute/service.py
  • tests — Unit tests for model construction and as_api_model() serialization
    • packages/gooddata-sdk/tests/compute/test_chat_context.py

Source commits (gdc-nas)

  • adffd00 feat(gen-ai): introduce UserContext to enhance chatbot capabilities
  • 09168a4 Merge pull request #21557 from Mara3l/smac-LX-2168
  • 247d62e Merge pull request #21436 from Mara3l/smac-LX-2199
  • 63dd6bf feat(gen-ai): refactor widgets polymorphism and enhance OpenAPI spec
OpenAPI diff
+      "UserContext": {
+        "properties": {
+          "userId": { "type": "string" },
+          "userEmail": { "type": "string" }
+        }
+      },
+      "DashboardContext": {
+        "properties": {
+          "dashboardId": { "type": "string" }
+        }
+      },
+      "UIContext": {
+        "properties": {
+          "timezone": { "type": "string" }
+        }
+      },
+      "RichTextWidgetDescriptor": {
+        "properties": {
+          "content": { "type": "string" },
+          "type": { "enum": ["RICH_TEXT"] }
+        }
+      }

Workflow run


Generated by SDK OpenAPI Sync workflow

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 20, 2026

Codecov Report

❌ Patch coverage is 87.93103% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.73%. Comparing base (c00ca3b) to head (ad98b0c).
⚠️ Report is 170 commits behind head on master.

Files with missing lines Patch % Lines
...s/gooddata-sdk/src/gooddata_sdk/compute/service.py 27.27% 8 Missing ⚠️
...sdk/src/gooddata_sdk/compute/model/chat_context.py 94.23% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #1577       +/-   ##
===========================================
+ Coverage    0.00%   78.73%   +78.73%     
===========================================
  Files         158      231       +73     
  Lines       11048    15517     +4469     
===========================================
+ Hits            0    12218    +12218     
+ Misses      11048     3299     -7749     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant