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)

1 Like

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.

Hi team — following up on ticket #21158 regarding the persistent Motoko build failures in authorization/access-control.mo and user‑approval/approval.mo.
I’ve retried multiple deployments implementing all prior suggestions, but the same compilation errors remain.
Could an engineer please review whether this may relate to an environment inconsistency, code‑generation mismatch, or caching issue?

I’ve attached the seven diagnostic screenshots I shared previously on Discord to help illustrate the compiler responses and error traces.

Thank you for reviewing this matter — any updates or guidance from the Caffeine / DFINITY engineering teams would be sincerely appreciated.

(Reference: Original Forum Post Link)

https://forum.dfinity.org/t/motoko-build-failures-in-authorization-access-control-mo-and-user-approval-approval-mo-persistent-compilation-errors-prevent-deployment

As of yesterday Caffeine AI chat is completely unresponsive and I cannot continue where I left off with my project. Also my whole entire chat history is gone so I have no way to go back and refer to anything. I do not see the progress number of Files under project name like it once showed, last it was at 66. I do still see code and spec data, but im not computer savvy to understand that, but I can always share information upon request if needed. I am stuck at a dead end road and now I am not sure if my project I worked extremely hard on is still there? I will attach the latest screenshots I have. The first screenshot was chat responding to the advice that was giving to me from a few team members on discord that I copy and pasted into chat trying to fix the existing build failures amd no visuals. Chat started giving me the instructions as it acknowledged the correct measures before app went down. I never aaplied anything as I was asking chat for detailed guidance. Second screenshot was chat speaking with a mind of its own not related to my questions and requests. I am very lost and confused now, Asking for help and guidance?