Motoko Build Failures in authorization/access-control.mo and user-approval/approval.mo – Persistent Compilation Errors Prevent Deployment

Hello DFINITY engineering team and community,

I’ve been developing a large Motoko-based project on the Internet Computer with complex backend modules. For several days, every build has failed due to persistent backend compilation errors specifically originating from these files:

  • authorization/access-control.mo

  • user-approval/approval.mo

These two modules appear to reinitialize OrderedMap.Make<Principal> inside multiple functions instead of reusing the shared maps declared in the state (AccessControlState and UserApprovalState). This leads to constant type mismatches, scoping conflicts, and failed compilation when attempting to build the actor TimeIsMoney. The compiler throws errors like “type mismatch,” “field not found,” or “cannot update immutable structure.”

What should happen:
Each module should reuse the already initialized maps in the shared state, not declare new ones inside each function. For example, the functions should update or read from state.userRoles or state.approvalStatus directly rather than creating local maps with new OrderedMap.Make calls.

Proposed fix direction:

  • Remove redundant let principalMap = OrderedMap.Make<Principal>(Principal.compare) inside each function.

  • Update all mutations to use state.userRoles := OrderedMap.put(state.userRoles, user, role) or similar shared references.

  • Ensure maps in state are declared mutable and accessed consistently across functions.

  • Validate that orderedMap.put operations reference the shared map instance to maintain compiler consistency.

Even though the frontend builds successfully, the backend cannot deploy until these Motoko logic errors are corrected. I’ve attempted multiple rebuilds without success.

Could someone from the DFINITY team please review this issue and confirm the correct pattern for updating shared OrderedMap state inside Motoko modules?

Any structural code suggestions or examples from official best practices would be deeply appreciated.

Thank you,
Travis Schaub

Founder – TIME (Time Is Money Enterprises LLC)

Hey, I assume this is a caffeine.ai project? Please ask on the Discord channel and include the project ID there
Join the caffeine.ai Discord Server!

2 Likes

Hi Kamil, thanks so much for getting back to me — I really appreciate your time. :folded_hands:t2:
Could you clarify what you mean by “project ID”? I don’t want to share any sensitive data, but I’m happy to provide whatever general or non‑confidential details would help diagnose the Motoko build issue.
The deployment consistently fails in authorization/access-control.mo and user-approval/approval.mo, so any insight into compiler behavior or structure conflicts would be greatly appreciated.

To get the project ID in caffeine.ai you need to click on the name/avatar of your app in the chat, then expand the ‘Information’ tab and there is the ‘ID’ field. Please post it together with the issue on the discord channel.

1 Like

“Thanks, Kamil — I’ll post my Project ID on the Discord channel as you recommended so the team can review the build issue. Appreciate your help!”

Follow‑Up Update (After Formal Submission)

The formal escalation package has now been officially submitted, including full compilation logs, version traces, dependency screenshots, and backend system audit visuals.

The issue remains focused on initialization and mutable‑state handling within OrderedMap and Principal operations across authorization/access-control.mo and user-approval/approval.mo. Both modules cause build termination at the Motoko compile stage due to type/variable mutability conflicts.

Project: Time Is Money Enterprises LLC

Build ID: 019a84c4‑582b‑7606‑9e7a‑94c6fc3604ee

Environment: Motoko v0.11.0 | DFX v0.15.4 | Caffeine AI + Internet Computer SDK

These files handle all core authentication, access‑control, and user‑approval logic, so their compilation failure prevents any canister deployment. I’ve documented every attempted restructuring, environment verification, and dependency audit in the attached materials for engineering review.

Given that Time Is Money Enterprises LLC represents one of the Internet Computer’s most comprehensive multi‑sector canister ecosystems, resolving this Motoko compiler‑dependency issue will highlight enterprise‑scale readiness and advance ICP’s adoption potential.

Thank you Kamil and team for taking a direct look — I’m available to provide full build logs or environment exports upon request.

Kind regards, Travis — Founder, Time Is Money Enterprises LLC

ICP Developer | Caffeine Ecosystem Member

Update:
I’m still encountering build failures when trying to deploy my project. The current error shown is: “deployment failed.”
The issue appears to be linked to the backend Motoko compilation stage. My latest code matches the version Ariel reviewed (including the access-control.mo and approval.mo updates).
No syntax changes have been made since the last review. Could someone please confirm whether this might be related to a current Motoko compiler or dependency error on the DFINITY side?

Thank you again for your continued support reviewing this — your insights are greatly appreciated.