Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Module name collision on different apps installed in different sites | GoodFirstPicks

Module name collision on different apps installed in different sites

frappe/frappe 2 comments 1mo ago
View on GitHub
highopenScope: somewhat clearSkill match: maybeFrappe / ERPNextPython

Why this is a good first issue

The issue involves core module mapping logic and requires careful handling of app dependencies.

AI Summary

The issue describes a module name collision problem in Frappe's module mapping system, where conflicting module names across apps cause ImportError. The fix requires modifying the core module mapping logic in `frappe/__init__.py` and potentially adding validation during app installation. The complexity is high due to the need to maintain backward compatibility and handle app dependencies correctly.

Issue Description

Description of the issue

When two independent apps declare a module with the same name in their modules.txt file, Frappe's module mapping system causes ImportError during app installation.

The root cause is in frappe/__init__.py:setup_module_map() which builds the local.module_app dictionary by iterating through apps and overwrites any existing module→app mapping when a duplicate module name is found. This means the last app processed wins, regardless of which app actually owns a specific DocType.

This creates a critical problem:

  • Database records (tabModule Def) show the first app that installed the module
  • In-memory cache (frappe.local.module_app) points to the last app in iteration order
  • Result: Frappe tries to load DocTypes from the wrong app, causing ImportError

Context information (for bug reports)

Output of bench version

frappe 15.x
erpnext 15.x

Affected file: frappe/frappe/__init__.py lines 1649-1688 (setup_module_map)

Steps to reproduce the issue

  1. Create two independent apps that both declare a module named "Stock" in their modules.txt:

    • App A (e.g., erpnext): Contains module "Stock" with DocType "Repost Item Valuation"
    • App B (e.g., appcustom): Contains module "Stock" but WITHOUT "Repost Item Valuation"
  2. Add both apps to sites/apps.txt in this order:

    frappe
    erpnext
    appcustom
    
  3. Create a new site and install App A (erpnext):

    bench new-site testsite
    bench --site testsite install-app erpnext
    

Observed result

Installation fails with:

ImportError: Module import failed for Repost Item Valuation, the DocType you're trying to open might be deleted.
Error: No module named 'appcustom.stock.doctype.repost_item_valuation'

What happens internally:

  1. During setup_module_map(), the function iterates through apps in order
  2. When processing erpnext: sets local.module_app["stock"] = "erpnext"
  3. When proces

GitHub Labels

bug

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!

Risk Flags

  • core functionality
  • potential breaking changes
  • requires architectural understanding
Loading labels...

Details

Points10 pts
Difficultyhigh
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno