Skip to content

fix: add .ts and .mjs to EditorConfig indent rules#28396

Closed
17hz wants to merge 3 commits into
langgenius:mainfrom
17hz:fix/editorconfig-add-ts-mjs-support
Closed

fix: add .ts and .mjs to EditorConfig indent rules#28396
17hz wants to merge 3 commits into
langgenius:mainfrom
17hz:fix/editorconfig-add-ts-mjs-support

Conversation

@17hz

@17hz 17hz commented Nov 19, 2025

Copy link
Copy Markdown
Contributor

Summary

The .editorconfig file was missing indent configuration for .ts (TypeScript) and .mjs (ES modules) files. Previously, only .js and .tsx files were covered, which could lead to inconsistent formatting across the codebase.

This PR updates the configuration from [*.{js,tsx}] to [*.{js,ts,tsx,mjs}] to ensure all JavaScript/TypeScript file variants follow the same 2-space indentation rules.

Screenshots

N/A - Configuration file change only

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

17hz and others added 2 commits November 15, 2025 12:45
…eness

The previous implementation used only node_id as the Redis cache key,
which could cause conflicts when different apps have nodes with the
same node_id. This fix adds app_id to the cache key pattern to ensure
uniqueness across different applications.

Changes:
- trigger_service.py: Updated cache key from {key}:{node_id} to {key}:{app_id}:{node_id}
- webhook_service.py: Applied the same fix for webhook trigger nodes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
The .editorconfig was missing indent configuration for .ts (TypeScript) and .mjs (ES modules) files. This could lead to inconsistent formatting across the codebase.
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Nov 19, 2025
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @17hz, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses two distinct areas: improving code formatting consistency and enhancing Redis cache management. It extends the .editorconfig rules to ensure uniform 2-space indentation for TypeScript and ES module files. Concurrently, it refines the Redis cache keys within the trigger and webhook services by integrating the application ID, which is crucial for preventing data conflicts in multi-application environments and ensuring that cached data is correctly scoped and isolated.

Highlights

  • EditorConfig Update: The .editorconfig file has been updated to include .ts (TypeScript) and .mjs (ES modules) files in its indentation rules, ensuring consistent 2-space indentation across a broader range of JavaScript/TypeScript files.
  • Redis Cache Key Enhancement: Redis cache keys in trigger_service.py and webhook_service.py have been modified to incorporate app.id. This change improves data isolation and prevents potential cache key collisions across different applications, enhancing the reliability of cached data.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request combines two unrelated changes. The first is a configuration update to .editorconfig to include .ts and .mjs files for consistent formatting, which is a good improvement.

The second, more significant change, is a critical bug fix in trigger_service.py and webhook_service.py. It correctly scopes Redis cache keys with the application ID to prevent cache collisions between different apps. This is an important fix.

However, I have two main concerns:

  1. Missing Tests: The PR description claims tests have been added, but I don't see any for the cache key changes. Given the critical nature of this fix, it's essential to add integration tests to verify that caches for different apps are now properly isolated.
  2. Misleading PR Description: The PR title and description only mention the .editorconfig change, completely omitting the bug fix. This makes it hard to understand the full scope of the changes.

I've left detailed comments on the need for tests. Ideally, these two changes should be in separate pull requests to follow the principle of atomic changes. Please consider updating the PR description to accurately reflect all changes.

node_id = node_info["node_id"]
# firstly check if the node exists in cache
if not redis_client.get(f"{cls.__PLUGIN_TRIGGER_NODE_CACHE_KEY__}:{node_id}"):
if not redis_client.get(f"{cls.__PLUGIN_TRIGGER_NODE_CACHE_KEY__}:{app.id}:{node_id}"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

This change correctly scopes the cache key to the application, fixing a potential cache collision bug. However, the PR does not include tests to verify this fix. Please add an integration test that creates nodes with the same ID in two different apps and confirms that their caches are handled independently without collisions.

On a related note for maintainability, the Redis cache key format is now constructed in multiple places within this method (lines 213, 258, 288, 298). Consider centralizing this logic to prevent future inconsistencies.

for node_id in nodes_id_in_graph:
# firstly check if the node exists in cache
if not redis_client.get(f"{cls.__WEBHOOK_NODE_CACHE_KEY__}:{node_id}"):
if not redis_client.get(f"{cls.__WEBHOOK_NODE_CACHE_KEY__}:{app.id}:{node_id}"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

This is a crucial fix to prevent cache collisions. However, similar to trigger_service.py, this change is not covered by tests. Please add an integration test to ensure that webhook node caches for different apps are properly isolated.

For maintainability, consider centralizing the cache key generation logic, as it's repeated on lines 815, 848, and 855.

@17hz

17hz commented Nov 19, 2025

Copy link
Copy Markdown
Contributor Author

Closing - branch was created from wrong base. Will recreate from main.

@17hz 17hz closed this Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant