Skip to content

fix: stop publish when agent compilation fails - #337

Open
konkonrong-lgtm wants to merge 1 commit into
forcedotcom:mainfrom
konkonrong-lgtm:fix/publish-aborts-on-compilation-failure
Open

fix: stop publish when agent compilation fails#337
konkonrong-lgtm wants to merge 1 commit into
forcedotcom:mainfrom
konkonrong-lgtm:fix/publish-aborts-on-compilation-failure

Conversation

@konkonrong-lgtm

Copy link
Copy Markdown

What does this PR do?

ScriptAgent.publish() recompiles the current AgentScript before publishing,
but it previously did not check the returned compilation status. AgentScript
syntax errors are returned as { status: "failure", compiledArtifact: null }
rather than thrown.

If the ScriptAgent already had an artifact cached from an earlier successful
compilation, publishing continued with that older artifact after the new
compilation failed.

This change stops publishing when compilation fails, clears the cached
artifact, and throws an AgentCompilationError containing the compilation
details.

The regression test reproduces the issue by returning a successful compilation
response followed by a failure response. Before this change,
ScriptAgentPublisher.publishAgentJson() was still called after the failure.

Tests:

  • yarn compile
  • yarn lint — 0 errors
  • yarn test:only — 407 passing, 1 pending
  • yarn nyc mocha "test/agents.test.ts" — 26 passing, 1 pending
  • yarn nyc mocha "test/agentPublisher.test.ts" — 20 passing

What issues does this PR fix or reference?

N/A

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant