dotCMS / dotCMS/core

Add logging to HostVariableAPIImpl for Site Variable operations

Open
#36,038 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

dotCMS : Technical Debt Team : Maintenance Type : Task
Dominant language
Java
Stars
970
Forks
486
Avg merge
3d 33m
Merged PRs (30d)
170

Description

Description

HostVariableAPIImpl — the core service class responsible for all Site Variable (Host Variable) CRUD operations — contains no logging whatsoever. This makes it impossible for the Enterprise Support Team to diagnose customer-reported issues related to Site Variables, as there is no audit trail of who performed an operation, on which variable, and when.

This is especially important because Site Variables are not propagated via Push Publishing (expected behavior), so server-side logs are the only reliable record of changes across environments.

The class is located at:
dotCMS/src/main/java/com/dotmarketing/portlets/hostvariable/bussiness/HostVariableAPIImpl.java

Operations that need logging
Method Operation type
save(HostVariable, ...) Single variable create/update
save(List<HostVariable>, ...) Batch create/update/delete
delete Variable deletion
copy Variable copy to another host
updateUserReferences User reference update (maintenance)
What should NOT be logged

Variable values must never appear in log entries — they frequently contain secrets such as API keys, passwords, and tokens.


Acceptance Criteria

  • delete logs at INFO: user ID, variable ID, host ID — value never included
  • save(HostVariable, ...) logs at INFO: user ID, variable key, variable ID (if pre-existing), host ID, and whether the operation was a create or update
  • save(List<HostVariable>, ...) logs at INFO: user ID, host ID, count of variables added, updated, and deleted in the batch
  • copy logs at INFO: user ID, source variable key/ID, destination host ID
  • updateUserReferences logs at INFO: userToDelete ID, userToReplace ID
  • Variable value is never present in any log entry across any method
  • All log statements use Logger.info(this, ...) — no System.out
  • Read operations (find, getVariablesForHost, getAllVariables) produce no log entries

Additional Context

  • Support context: when a customer reports unexpected Site Variable state (e.g., a variable was changed or deleted without their knowledge), Support currently has no way to confirm what happened or who performed the action.
  • The save(List<HostVariable>, ...) method performs implicit deletes for variables removed from the incoming list — these deletions must appear in the log so Support can identify them.
  • Push Publishing does NOT distribute Site Variables — this is by design. Logging is therefore the primary traceability mechanism for cross-environment issues.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in dotCMS/src/main/java/com/dotmarketing/portlets/hostvariable/bussiness/HostVariableAPIImpl.java and inspect save, delete, copy, and updateUserReferences. Add INFO logging with Logger.info(this, ...) for the specified operation details, ensuring values and read operations are excluded; done when every acceptance criterion is met.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, observability
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.