Skip to content

Fix fwreinit failing to find server when web.webroot is set in server.json#41

Merged
lmajano merged 2 commits intodevelopmentfrom
copilot/fix-webroot-setting-recognition
Mar 27, 2026
Merged

Fix fwreinit failing to find server when web.webroot is set in server.json#41
lmajano merged 2 commits intodevelopmentfrom
copilot/fix-webroot-setting-recognition

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 27, 2026

When a server is started with a custom web.webroot in server.json (common in module development setups using test-harness as the webroot), fwreinit fails with "No server configurations found" because it was discovering servers by matching the CWD against the server's webroot path.

Changes

  • Server lookup by name instead of path — replaces getServerInfoByDiscovery(getCWD(), name) with getServerInfoByDiscovery(name=arguments.name), bypassing the webroot path mismatch entirely
  • Auto-resolve server name from server.json — adds getDefaultServerName() which reads the server name registered in server.json via getServerInfoByDiscovery(serverConfigFile="server.json"), making the name parameter self-populating without user input
  • Null-safe fallback — guards against missing server.json or unregistered servers by checking keyExists("name") before returning
private function getDefaultServerName(){
    var serverInfo = serverService.getServerInfoByDiscovery( serverConfigFile = "server.json" );
    return serverInfo.keyExists( "name" ) ? serverInfo.name : "";
}

📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI changed the title [WIP] Fix framework reinit to recognize webroot setting in server.json Fix fwreinit failing to find server when web.webroot is set in server.json Mar 27, 2026
Copilot AI requested a review from lmajano March 27, 2026 10:28
@lmajano lmajano marked this pull request as ready for review March 27, 2026 10:32
Copilot AI review requested due to automatic review settings March 27, 2026 10:32
@lmajano lmajano merged commit 3be68af into development Mar 27, 2026
5 checks passed
@lmajano lmajano deleted the copilot/fix-webroot-setting-recognition branch March 27, 2026 10:32
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes fwreinit server discovery when a CommandBox server is started with a custom web.webroot in server.json by shifting discovery away from CWD/webroot matching and toward server-name-based lookup.

Changes:

  • Default the name argument to the server name discovered from server.json.
  • Update server discovery to use getServerInfoByDiscovery( name = ... ) instead of CWD-based discovery.
  • Adjust the “no server found” messaging to include the name being searched for.

Comment on lines +29 to 31
var serverInfo = serverService.getServerInfoByDiscovery( name = arguments.name );

if ( !structCount( serverInfo ) ) {
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

Switching to name-only discovery means coldbox reinit can no longer fall back to discovering the running server by the current working directory. If getDefaultServerName() returns an empty string (e.g., no server.json in the CWD or the server isn’t registered), getServerInfoByDiscovery( name = "" ) will likely return no match where the previous CWD-based discovery would have succeeded. Consider adding a fallback: if arguments.name is blank (or the name lookup returns an empty struct), attempt discovery using the CWD (or the server.json path) before failing.

Suggested change
var serverInfo = serverService.getServerInfoByDiscovery( name = arguments.name );
if ( !structCount( serverInfo ) ) {
var serverInfo = {};
// Try name-based discovery first if we have a non-blank name
if ( len( trim( arguments.name ) ) ) {
serverInfo = serverService.getServerInfoByDiscovery( name = arguments.name );
}
// Fallback: attempt discovery using the server.json in the current working directory
if ( !structCount( serverInfo ) ) {
serverInfo = serverService.getServerInfoByDiscovery( serverConfigFile = "server.json" );
}
if ( !structCount( serverInfo ) ) {

Copilot uses AI. Check for mistakes.
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.

3 participants