What the agent does
The agent clones the repository into its own cloud sandbox and finds where moment is handed a string with no format. In a small command-line tool like IonicaBizau/ghcal, package.json depends on moment at ^2.10.6, which resolves to the newest 2.x on every install, and there is no lock file. bin/ghcal requires moment at line 12 and, at lines 60 and 61, turns the --since and --until options into Moment(sinceDateOpt.value) and Moment(untilDateOpt.value): whatever the person typed goes straight to the constructor. Line 16 is the tell: Moment.suppressDeprecationWarnings = true;, which hides the warning instead of fixing its cause. The README's own examples pass -s '1 January 2015', a spelling moment only understands by falling back to the JavaScript Date constructor.
Then it reproduces the warning in the repository's own node_modules. Moment("25/12/2020") prints Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. with a stack trace into moment.js, and the result is invalid. Moment("1 January 2015") prints the same warning but comes back valid, because Date happens to parse it, which is exactly the unreliability the message describes. Moment("2020-12-25") is silent. So the tool works on the maintainer's machine, prints a wall of text for anyone who types a date another way, and silently produces an invalid date for 25/12/2020.
The fix is to say which spellings are accepted. The agent adds a parseDate helper in bin/ghcal that calls Moment(value, formats, true) with a strict list: Moment.ISO_8601, "D MMMM YYYY", "MMMM D YYYY", "D MMM YYYY" and "YYYY-MM-DD", covering the README's examples and the ISO form. An input that matches none of them is reported as Invalid --since date: 'not a date'. Use a date like '1 January 2015' or '2015-01-01'. through the tool's existing bug-killer logger, and the process exits 1 before any request is made. The suppressDeprecationWarnings line is deleted, because nothing calls the fallback any more.
It checks what the parsed value feeds. The cli-gh-cal dependency documents start and end as a parsable string, a Date or a moment, and uses them as moments: options.end.diff(options.start, "weeks") and options.start.add(...), so a strict moment is the same type it had before. The agent also notes that package.json declares "test": "node test" but the repository has no test directory, so there is no suite to extend; the pull request shows the before and after parses instead.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Our logs show moment's \"Deprecation warning: value provided is not in a recognized RFC2822 or ISO format\" message. Read package.json and every file that calls moment first. Find each call that passes a string without a format, reproduce the warning with the repository's installed moment and quote it. Replace each one with strict parsing against an explicit list of the formats we document, reject input that matches none of them with a clear error, and remove any suppressDeprecationWarnings setting. Show the same inputs parsing silently afterwards, run whatever tests exist, and open a pull request that quotes the before and after.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
What comes back is a pull request touching the file that parses the dates, bin/ghcal in this tool: the suppression line removed, a parseDate helper with the strict format list, and the two option reads going through it. The description quotes the warning as the current moment prints it for 25/12/2020, shows that the same input is now rejected with the new error message, and shows 1 January 2015, 1 Mar 2015, March 1 2015 and 2015-01-01 all parsing to the expected day without a line of output.
A reviewer checks the format list against the documentation: every spelling the README promises is in it, strict mode means 01/03/2015 is refused rather than guessed as January 3 or March 1, and the error names the formats a person should use. They also check that nothing downstream expected a Date rather than a moment. The run's record holds each parse with its output, so the before and after are read from the transcript rather than from the description.
Run it on every log line with the warning
Add an automation to the Project with this prompt and a webhook trigger. A Grafana alert rule on the log line value provided is not in a recognized RFC2822 or ISO format can call the trigger's URL from a contact point with the Authorization: Bearer header the trigger needs, and one run starts per firing with the alert payload after the prompt. Give the contact point an Idempotency-Key for the trigger's URL made from the alert's fingerprint, so a repeated notification does not start a second run.
A deprecation like this is usually found during a dependency bump instead, so the same prompt also fits a schedule trigger that runs each Monday in your timezone: when the bump of moment or of Node changes nothing, the run opens nothing.
The use case this job follows, with its automation and trigger: Fix a bug from an alert.
Why run it on Rush?
Moment prints this warning once per process and then goes quiet, which is why the suppression line exists: on a laptop it is noise, in production it is the only sign that 25/12/2020 turned into an invalid date. The agent runs the repository's own moment build in its sandbox, keeps the exact warning and stack trace in the run's record, and the pull request shows the inputs that used to fall back to Date next to how they parse now.
The change is small, but the decision inside it is not: which spellings a tool accepts. The agent reads the README and the help text to find the formats already promised, puts exactly those in the list, and leaves the choice visible in one place, so a reviewer who wants DD/MM/YYYY as well adds one string rather than reopening the question.
Frequently asked questions
Why not just keep suppressDeprecationWarnings on?
Because the warning is about correctness, not noise. Without a format, moment hands the string to the JavaScript Date constructor, whose parsing differs between engines, and a string it cannot parse becomes an invalid moment that formats as Invalid date later. Suppressing the message keeps the behavior and loses the only hint.
Should the parse be strict?
The agent passes true as the third argument, so 01/03/2015 is refused instead of being read as March 1 in one locale and January 3 in another. If a format you want is missing, it is one more string in the list; strict parsing with a documented list is safer than lenient parsing with a guess.
What about moment(Date) or moment(number) calls?
Those never print this warning; only strings without a format do. The agent leaves them alone and lists them in the pull request so the reviewer sees they were considered.
Will it migrate away from moment?
Not in this change. Replacing moment with Day.js or date-fns is a separate job with its own pull request; this one makes the existing moment calls parse deterministically, which is also the first step of any later migration.
More Moment.js jobs
More jobs like this: Fix a bug from an alert
- Fix "Model.find() no longer accepts a callback" After a Mongoose Upgrade (Mongoose)
- Fix "DeprecationWarning: Mongoose: the `strictQuery` option will be switched back to `false` by default in Mongoose 7" (Mongoose)
- Fix "MongoParseError: options usecreateindex, usefindandmodify are not supported" in Mongoose 6 and Later (Mongoose)
- Fix Alembic Multiple Heads After a Merge (Alembic)
- Fix "OSError: mysql_config not found" When Installing a Flask App's Requirements (mysqlclient)