Skip to content

feat: Add dashboard user to job schedule execution description#3397

Open
codeKonami wants to merge 1 commit into
parse-community:alphafrom
codeKonami:feat/job-run-dashboard-user
Open

feat: Add dashboard user to job schedule execution description#3397
codeKonami wants to merge 1 commit into
parse-community:alphafrom
codeKonami:feat/job-run-dashboard-user

Conversation

@codeKonami

@codeKonami codeKonami commented Jul 8, 2026

Copy link
Copy Markdown

Pull Request

Issue

There is currently no way to tell who triggered a Cloud Code job from the dashboard. When a job is run manually via Jobs → Run now, the resulting _JobStatus entry always has the same generic description:

Executing from job schedule web console.

On a dashboard instance shared by several users (dashboard authentication with multiple users configured), this makes it impossible to audit which dashboard operator started a given job run.

Closes:

Approach

Include the currently logged-in Parse Dashboard user (the dashboard authentication user, not a Parse _User of the app) in the job execution description, so the _JobStatus record reads:

Executing from job schedule web console by <dashboard-user>.

This provides a simple, built-in level of auditability of job executions triggered from the dashboard.

Implementation details:

  • The dashboard user is already exposed by the server as the username HTTP response header on the main dashboard route (Parse-Dashboard/app.js, res.append('username', req.user.matchingUsername)), and is consumed the same way by the sidebar (src/components/Sidebar/Sidebar.react.js).
  • ParseApp.runJob now reads that header and, when present, appends by <user> to the job description before posting the job.
  • Backward compatible / safe fallback: if the dashboard has no authentication configured (no username header) or the lookup fails for any reason, the original description Executing from job schedule web console. is used unchanged.

Tasks

  • Add tests
  • Add changes to documentation (guides, repository pages, in-code descriptions)

Note: no user-facing docs describe this internal job description string, so no documentation change is required. The CHANGELOG is generated automatically by semantic-release from the commit message, so no manual changelog entry is added.

Summary by CodeRabbit

  • New Features
    • Job submissions now include the dashboard username in the job description when available, making submitted jobs easier to identify.
  • Bug Fixes
    • If the username can’t be read, job submissions now fall back to the standard default description.
    • Improved reliability of job submission behavior when dashboard lookup requests fail.

Include the logged-in Parse Dashboard user in the job execution
description ("Executing from job schedule web console by <user>.") to
provide a basic level of auditability of who triggered a job from the
dashboard. Falls back to the previous description when no dashboard user
is configured or cannot be determined.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 8, 2026 10:05
@parse-github-assistant

Copy link
Copy Markdown

🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review.

Tip

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

Note

Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect.

Caution

Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

ParseApp.runJob is changed to an async method that fetches the dashboard path to read a username response header and includes it in the job description sent via Parse._request, falling back to a default description when unavailable. A new test file covers these scenarios.

Changes

Job description username lookup

Layer / File(s) Summary
Async runJob with username lookup
src/lib/ParseApp.js
runJob becomes async, fetches window.PARSE_DASHBOARD_PATH (or /) to read a username header, and builds the job description accordingly before calling Parse._request.
Test setup and mocks
src/lib/tests/ParseApp.test.js
New Jest jsdom test file adds helpers to construct a test ParseApp, mock global.fetch for username headers, and mock Parse._request in beforeEach.
Description behavior test cases
src/lib/tests/ParseApp.test.js
Tests verify description includes username when header is present, falls back to default when header is null, and falls back to default when fetch rejects.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant ParseApp
  participant DashboardServer
  participant ParseServer

  Caller->>ParseApp: runJob(job)
  ParseApp->>DashboardServer: fetch(PARSE_DASHBOARD_PATH)
  alt username header present
    DashboardServer-->>ParseApp: response with username header
    ParseApp->>ParseApp: description includes username
  else fetch fails or no username
    DashboardServer-->>ParseApp: error or null username
    ParseApp->>ParseApp: description uses default
  end
  ParseApp->>ParseServer: Parse._request('POST', 'jobs', {input, jobName, when: 0, description})
  ParseServer-->>ParseApp: response
  ParseApp-->>Caller: result
Loading

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Engage In Review Feedback ❓ Inconclusive Repo shows one feature commit and no review-thread artifacts or follow-up commits proving feedback was discussed and addressed; this can't be verified from code alone. Provide linked review comments or a follow-up commit/discussion showing the feedback was addressed or retracted before resolving it.
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the change and uses the required feat: prefix with a capitalized first word.
Description check ✅ Passed The description includes the required Pull Request, Issue, Approach, and Tasks sections and is sufficiently detailed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Check ✅ Passed No vuln pattern found: the username header is already used in Sidebar, runJob falls back safely, and job descriptions render as text, not HTML.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR improves auditability for Cloud Code jobs triggered from the Parse Dashboard by including the currently logged-in dashboard auth user in the _JobStatus.description when running a job via Jobs → Run now.

Changes:

  • Update ParseApp.runJob to read the username response header from the dashboard route and append it to the job execution description when present.
  • Add Jest coverage for the new behavior, including fallback behavior when the username is missing or lookup fails.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/lib/ParseApp.js Adds dashboard-user attribution to the job execution description by reading the username header.
src/lib/tests/ParseApp.test.js Adds unit tests verifying user attribution and fallback behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +32 to +36
describe('ParseApp.runJob', () => {
beforeEach(() => {
Parse._request = jest.fn(() => Promise.resolve({}));
window.PARSE_DASHBOARD_PATH = '/';
});
Comment thread src/lib/ParseApp.js
Comment on lines +589 to +598
let description = 'Executing from job schedule web console.';
try {
const response = await fetch(window.PARSE_DASHBOARD_PATH || '/');
const dashboardUser = response.headers.get('username');
if (dashboardUser) {
description = `Executing from job schedule web console by ${dashboardUser}.`;
}
} catch {
// If the dashboard user cannot be determined, fall back to the default description.
}

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/lib/tests/ParseApp.test.js (1)

32-36: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add afterEach to restore global.fetch and window.PARSE_DASHBOARD_PATH.

The beforeEach sets Parse._request and window.PARSE_DASHBOARD_PATH, and each test overwrites global.fetch, but nothing restores these globals after the suite runs. Adding afterEach prevents potential leakage if the jsdom environment is reused across test files.

♻️ Proposed fix
   beforeEach(() => {
     Parse._request = jest.fn(() => Promise.resolve({}));
     window.PARSE_DASHBOARD_PATH = '/';
   });
+
+  afterEach(() => {
+    jest.restoreAllMocks();
+    delete global.fetch;
+    delete window.PARSE_DASHBOARD_PATH;
+  });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/tests/ParseApp.test.js` around lines 32 - 36, The ParseApp test suite
leaves global state behind because `beforeEach` and the tests mutate
`global.fetch` and `window.PARSE_DASHBOARD_PATH` without restoring them. Add an
`afterEach` in `ParseApp.test.js` alongside `describe('ParseApp.runJob', ...)`
to reset both values to their original state after every test, so the jsdom
environment and shared globals do not leak across test files.
src/lib/ParseApp.js (1)

590-598: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Use HEAD with a short timeout here
This only needs the username header. The dashboard route already sets that header before sending the HTML, so HEAD avoids downloading the body; add an abort timeout too so job execution doesn’t hang on a slow dashboard.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/ParseApp.js` around lines 590 - 598, The dashboard user lookup in
ParseApp’s description-building logic is fetching the full page body when it
only needs the username header. Update the `fetch` call in the job-schedule
console path to use a `HEAD` request instead of the default method, and add a
short abort timeout so the `description` fallback in `ParseApp` doesn’t hang on
a slow dashboard response.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/lib/ParseApp.js`:
- Around line 590-598: The dashboard user lookup in ParseApp’s
description-building logic is fetching the full page body when it only needs the
username header. Update the `fetch` call in the job-schedule console path to use
a `HEAD` request instead of the default method, and add a short abort timeout so
the `description` fallback in `ParseApp` doesn’t hang on a slow dashboard
response.

In `@src/lib/tests/ParseApp.test.js`:
- Around line 32-36: The ParseApp test suite leaves global state behind because
`beforeEach` and the tests mutate `global.fetch` and
`window.PARSE_DASHBOARD_PATH` without restoring them. Add an `afterEach` in
`ParseApp.test.js` alongside `describe('ParseApp.runJob', ...)` to reset both
values to their original state after every test, so the jsdom environment and
shared globals do not leak across test files.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fdfbed22-c473-4dbc-bd08-ace916392445

📥 Commits

Reviewing files that changed from the base of the PR and between 9db24be and 078807c.

📒 Files selected for processing (2)
  • src/lib/ParseApp.js
  • src/lib/tests/ParseApp.test.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants