Skip to content

Conversation

@msyavuz
Copy link
Member

@msyavuz msyavuz commented Jan 6, 2026

SUMMARY

Move translation function and logging from @superset-ui/core to new @apache-superset/core as part of the extensions project.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

Translations and logs should work across the app and be available in extensions

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@netlify
Copy link

netlify bot commented Jan 6, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit fc4a248
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6961348242eb610008538a00
😎 Deploy Preview https://deploy-preview-36929--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@msyavuz msyavuz moved this from To Do to In Progress in Superset Extensions Jan 6, 2026
@msyavuz msyavuz self-assigned this Jan 6, 2026
@msyavuz msyavuz force-pushed the msyavuz/chore/move-translator branch from be62782 to 1d96bc7 Compare January 7, 2026 09:55
@msyavuz msyavuz force-pushed the msyavuz/chore/move-translator branch from 5d3d9bc to e8b1b24 Compare January 7, 2026 18:08
@msyavuz msyavuz marked this pull request as ready for review January 7, 2026 18:11
@dosubot dosubot bot added the i18n Namespace | Anything related to localization label Jan 7, 2026
@codeant-ai-for-open-source
Copy link
Contributor

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@github-actions github-actions bot removed the i18n Namespace | Anything related to localization label Jan 7, 2026
*/
import { ReactNode } from 'react';
import { JsonValue, t } from '@superset-ui/core';
import { t } from '@apache-superset/core';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Importing the translation helper from the application-specific module instead of the shared UI core module couples this reusable chart-controls package to the app bundle and can cause runtime module resolution errors (or missing peer dependency issues) when @superset-ui/chart-controls is used outside the main Superset frontend; it should continue to import t from the shared @superset-ui/core package instead. [possible bug]

Severity Level: Critical 🚨

Suggested change
import { t } from '@apache-superset/core';
import { t } from '@superset-ui/core';
Why it matters? ⭐

The PR's final file imports t from '@apache-superset/core', which is an application-specific package.
This chart-controls package is intended to be a reusable library; depending on the app package will
couple the library to the superset frontend build and can cause resolution/peer-dependency issues for
external consumers. Importing t from '@superset-ui/core' (the shared UI core) is the correct choice
for a reusable package and fixes a real packaging/runtime coupling problem rather than being merely
cosmetic.

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/components/RadioButtonControl.tsx
**Line:** 20:20
**Comment:**
	*Possible Bug: Importing the translation helper from the application-specific module instead of the shared UI core module couples this reusable chart-controls package to the app bundle and can cause runtime module resolution errors (or missing peer dependency issues) when `@superset-ui/chart-controls` is used outside the main Superset frontend; it should continue to import `t` from the shared `@superset-ui/core` package instead.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.

Copy link
Member

@michael-s-molina michael-s-molina Jan 8, 2026

Choose a reason for hiding this comment

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

@superset-ui/chart-controls declares @apache-superset/core as its dependency.

@codeant-ai-for-open-source
Copy link
Contributor

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • API breaking change
    The file previously exported a default language pack. That export was removed and only logging is re-exported now. Consumers that imported the language pack or translation utilities from this module will break unless the PR provides a compatibility re-export or all call sites were updated to the new package (@apache-superset/core). Verify all imports across the monorepo and extensions are updated, or add a proxy re-export to preserve backward compatibility.

  • Mixed core packages
    The file now imports t from @apache-superset/core but still imports DTTM_ALIAS, QueryColumn, and QueryMode from @superset-ui/core. Mixing two core packages can produce duplicate runtime instances, inconsistent types, or diverging implementations of shared utilities. Confirm these symbols intentionally remain in @superset-ui/core and ensure both packages are compatible (same versions / singletons) to avoid subtle runtime or bundling issues.

  • ID / key safety
    DOM id and React key are derived directly from val (including JSON.stringify(val) and tab-${val}). If val is an object, array, or contains characters not valid in an id, this can produce invalid/duplicate ids or unpredictable keys. Use a stable stringification or index-based fallback to generate safe ids/keys.

  • Translation substitution
    The translated accessibility string uses a label value that can be a ReactNode (not necessarily a string). Passing a non-string as the translation placeholder can yield incorrect output (e.g. "[object Object]") or lose meaningful label text. Ensure the substituted value is converted/sanitized to a user-visible string before calling t.

  • Reset does not clear implicit singleton
    If getInstance() is called before configure(), a Translator is created and assigned to singleton while isConfigured remains false. resetTranslation() only clears singleton when isConfigured is true, so the implicitly-created singleton will not be cleared. This can lead to stale state across tests or when trying to reconfigure the translator.

  • Missing runtime dependency risk
    Moving t import to @apache-superset/core can cause runtime module resolution failures if the new package isn't added to this package's dependencies or isn't present at runtime. Ensure @apache-superset/core is a declared dependency (or peerDependency) and is bundled/published where this plugin runs.

  • Dependency change
    The translation function t is now imported from @apache-superset/core. Verify that this package is added to the package.json (or the consuming package's dependencies) and that the monorepo build and bundler configuration are updated so the new package is available at runtime. Missing/incorrect dependency changes will cause runtime/module resolution failures.

  • i18n runtime compatibility
    Ensure the t implementation exported from @apache-superset/core is API-compatible with prior usage (same signature and runtime behavior). Also confirm translations are loaded/initialized correctly in environments that consume this plugin (extensions, tests, storybooks).

  • I18n import change
    The PR moves t and tn imports to @apache-superset/core/ui. Confirm that the new exports behave identically to the previous @superset-ui/core implementations (pluralization, interpolation, runtime side-effects). Also ensure there's no mixed usage elsewhere in the repo that would import translations from the old package, which could lead to inconsistent translations at runtime.

  • Inconsistent imports
    The PR moves translation t to @apache-superset/core while validators (validateInteger, validateNonEmpty) remain imported from @superset-ui/core. This creates mixed core packages in the same module and can cause runtime/packaging inconsistencies if validators are also moved to the new core or re-exported differently. Verify the canonical source for shared utilities and align imports across the repo.

  • Export / resolution risk
    Ensure t is actually exported from @apache-superset/core in the version used by the app and that moving it did not create circular dependency or runtime resolution issues. Also verify tree-shaking / bundle size implications and update any consumers that still import t from @superset-ui/core.

  • Swallowed errors during image fetch
    The new logic catches fetch errors when checking the image, treats a 404 as "not ready", but silently swallows all other errors (no rethrow). That can cause non-404 failures to be treated as if the image was ready (or simply ignored), preventing proper retry/failure handling and logging. Ensure non-404 errors are propagated so retries/failure handling and logging behave as intended.

  • Module initialization side effects
    The code calls getExtensionsRegistry() at module scope (top-level) which can run during module evaluation. This may trigger side effects too early (e.g., during server-side rendering, tests, or before runtime initialization). Consider delaying registry resolution to component render or using lazy initialization to avoid ordering issues.

  • Logging API shape
    The code calls logging.error(error). Confirm that the logging export from @apache-superset/core exposes an error method with the expected signature. If the logging API changed during refactor, adapt the calls or wrap the new logger to preserve behavior.

  • Feature flag source
    Ensure FeatureFlag and isFeatureEnabled are still meant to be imported from @superset-ui/core. If the "move translations to new core" refactor also relocated feature-flag utilities to @apache-superset/core, this import will break at runtime or cause inconsistent behavior. Verify the canonical source and update imports accordingly.

  • Error surface/visibility
    The catch block clears state but does not surface the error to the user or log it. Consider logging the caught error and/or showing a danger toast so failures to fetch metadata are visible to users and debuggable in logs.

  • Mixed core package imports
    This file now imports t and logging from @apache-superset/core while SupersetClient remains imported from @superset-ui/core. Having core utilities split across two packages can introduce duplicated runtime instances (i18n, logging singletons) or incompatible versions. Validate that these packages are intentionally split, that peerDependencies/aliases will dedupe them at build/runtime, and that no re-exports were intended so everything resolves to a single implementation.

  • Mixed core packages
    The PR imports translation (t) from @apache-superset/core while still importing SupersetClient and getClientErrorObject from @superset-ui/core. This can lead to shipping two overlapping "core" packages, duplicate runtime code, and inconsistent exports across the app. Verify whether SupersetClient and getClientErrorObject should also be re-exported from @apache-superset/core (or vice versa), and ensure all callers are updated consistently to avoid bundle duplication or runtime mismatches.

  • Import inconsistency
    The PR moved t and logging to @apache-superset/core but left SupersetClient imported from @superset-ui/core. This mixed sourcing can cause duplicate/core-version mismatches, subtle runtime differences, or larger bundles. Verify which package is the single source-of-truth for core utilities and make imports consistent.

  • Packaging / bundle size risk
    Importing related utilities from two different packages risks pulling both packages into the client bundle (duplicate code). Confirm whether @apache-superset/core re-exports SupersetClient and, if so, consolidate imports to avoid duplication and ensure consistent runtime behavior.

  • Mixed import sources
    The PR moves logging and t to @apache-superset/core while keeping SupersetClient (and many other UI components) imported from @superset-ui/core. Mixing the old and new packages for related runtime utilities may cause version mismatches, duplicate instances, or context differences (e.g., different singletons for logging or translation state). Verify the packages are aligned and the same logical implementations are used across the app.

  • Translation import location
    t is now imported from @apache-superset/core/ui. Ensure the translation registry and message catalogs remain wired properly after the move so translations resolve the same way. Confirm there are no duplicate t implementations still referenced elsewhere.

  • Translation import path
    The t function was moved from @superset-ui/core to @apache-superset/core/ui. Verify that the new import path is correct and that @apache-superset/core is present in this package's dependencies (or a top-level workspace) so the module resolves at runtime. Confirm that other plugins were updated consistently to avoid mixed imports.

  • Dependency / build changes required
    Moving t to @apache-superset/core likely requires changes to repository-level package.json and build config (new dependency, possible storybook/test config updates). Ensure CI and consumers (extensions) add the new package and that rollouts are coordinated to avoid missing import errors.

  • Dependency duplication / compatibility
    Adding @apache-superset/core while @superset-ui/core remains used for ChartPlugin/ChartMetadata may create two sources of truth for shared utilities. Verify there are no conflicting implementations/version mismatches that could lead to duplicate bundles or inconsistent behavior.

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

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

Thank you for the PR @msyavuz. There are some small tweaks to test and README files but let's do them in a follow-up due to the high potential for conflicts in this PR.

@michael-s-molina
Copy link
Member

@villebro or @rusackas Can you stamp as code owners?

jest.resetAllMocks();
});

it('should pipe to `console` methods', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
it('should pipe to `console` methods', () => {
test('should pipe to `console` methods', () => {

expect(() => logging.trace()).toThrow('Trace:');
});

it('should use noop functions when console unavailable', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
it('should use noop functions when console unavailable', () => {
test('should use noop functions when console unavailable', () => {

*/
import UntypedJed from 'jed';
import logging from '../utils/logging';
import logging from '../../utils/logging';
Copy link
Member

Choose a reason for hiding this comment

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

The README file is still referencing @superset-ui/core.

@michael-s-molina michael-s-molina moved this from In Progress to In Review in Superset Extensions Jan 8, 2026
@michael-s-molina michael-s-molina changed the title refactor: move translations to new core refactor: move translations and logging to new core Jan 8, 2026
@rusackas rusackas requested a review from Copilot January 9, 2026 16:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR moves translation (t, tn, configure) and logging functions from @superset-ui/core to the new @apache-superset/core package as part of the extensions project. The changes update import statements across the codebase to use the new package location.

Changes:

  • Translation functions moved to @apache-superset/core with updated imports across ~300+ files
  • Logging utility moved to @apache-superset/core with corresponding import updates
  • Test files relocated and updated to reflect new package structure

Reviewed changes

Copilot reviewed 293 out of 704 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
superset-frontend/packages/superset-ui-core/src/index.ts Removed translation exports from old core package
superset-frontend/packages/superset-core/src/index.ts Added utils exports to new core package
superset-frontend/packages/superset-core/src/ui/index.ts Added translation exports to UI module
superset-frontend/spec/helpers/shim.tsx Updated translation configuration import path
superset-frontend/packages/superset-ui-core/test/utils/featureFlag.test.ts Updated imports to use new core package for logging
All SqlLab files Updated translation imports from @superset-ui/core to @apache-superset/core
All plugin files Updated translation imports to new package location
All validator files Updated translation imports for error messages

expect(uiCore.isFeatureEnabled(uiCore.FeatureFlag.DrillBy)).toEqual(false);
expect(isFeatureEnabled(FeatureFlag.DrillBy)).toEqual(false);
expect(uiCore.logging.error).toHaveBeenCalled();
expect(logging).toHaveBeenCalledWith('Failed to query feature flag DRILL_BY');
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

Line 61 references an undefined variable logging. This should be uiCore.logging.error to match the mock being tested on line 60.

Suggested change
expect(logging).toHaveBeenCalledWith('Failed to query feature flag DRILL_BY');
expect(uiCore.logging.error).toHaveBeenCalledWith('Failed to query feature flag DRILL_BY');

Copilot uses AI. Check for mistakes.
*/
import UntypedJed from 'jed';
import logging from '../utils/logging';
import logging from '../../utils/logging';
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The import path uses relative paths across multiple directory levels (../../). Consider using an absolute import from the package root for better maintainability and clarity.

Suggested change
import logging from '../../utils/logging';
import logging from 'src/utils/logging';

Copilot uses AI. Check for mistakes.
Comment on lines +27 to +28
jest.mock('@apache-superset/core/ui', () => ({
...jest.requireActual('@apache-superset/core/ui'),
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The mock is now targeting the entire @apache-superset/core/ui module instead of the more specific theme/utils/themeUtils path. This broader mock could hide issues with other exports from the ui module. Consider maintaining the more specific mock target if possible.

Suggested change
jest.mock('@apache-superset/core/ui', () => ({
...jest.requireActual('@apache-superset/core/ui'),
jest.mock('@apache-superset/core/ui/theme/utils/themeUtils', () => ({
...jest.requireActual('@apache-superset/core/ui/theme/utils/themeUtils'),

Copilot uses AI. Check for mistakes.

/**
* Superset frontend logger, currently just an alias to console.
* Superset logger, currently just an alias to console.
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The comment was updated from 'Superset frontend logger' to 'Superset logger', but this is still in the frontend package. The comment should clarify that this is for frontend logging to avoid confusion.

Suggested change
* Superset logger, currently just an alias to console.
* Superset frontend logger, currently just an alias to the browser console.

Copilot uses AI. Check for mistakes.
Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

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

LGTM! The only thing I'll mention (for this or a follow-up PR) is that Storybook stories for modules/components available to extensions show up in the docs. We should make sure that Extension-available components all have storybook entries, but also I'm wondering if certain utils like t() or logging - while not components - are storybook-worthy in that way as well.... it's a bit odd, but might make sense.

@rusackas
Copy link
Member

rusackas commented Jan 9, 2026

I wonder if it's worth documenting somewhere WHY we use this logging service... it's partly to make sure console calls get alerted/removed by developers, but mainly for safety, where not all browsers have all these methods.

Most devs probably don't even know about console.table, but this allows us to use it freely... which we should probably do more often ;)

@msyavuz msyavuz force-pushed the msyavuz/chore/move-translator branch from 6626e8f to fc4a248 Compare January 9, 2026 17:01
@codeant-ai-for-open-source
Copy link
Contributor

CodeAnt AI is running Incremental review


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

3 participants