Skip to content

Commit 892a5df

Browse files
authored
fix: error message should not be set with other fields (#710)
* fix: error message should not be set with other fields The server should just return the flag if the agent is unidentified (service.name not known). * add server log message
1 parent 1dc8ec4 commit 892a5df

File tree

3 files changed

+2
-12
lines changed

3 files changed

+2
-12
lines changed

extension/apmconfigextension/integration_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,6 @@ func apmConfigintegrationTest(name string) func(t *testing.T) {
113113
InstanceUid: []byte("test"),
114114
Capabilities: uint64(protobufs.ServerCapabilities_ServerCapabilities_OffersRemoteConfig),
115115
Flags: uint64(protobufs.ServerToAgentFlags_ServerToAgentFlags_ReportFullState),
116-
ErrorResponse: &protobufs.ServerErrorResponse{
117-
ErrorMessage: "error retrieving remote configuration: agent could not be identified: service.name attribute must be provided",
118-
Type: protobufs.ServerErrorResponseType_ServerErrorResponseType_Unknown,
119-
},
120116
},
121117
},
122118
},
@@ -266,10 +262,6 @@ func apmConfigintegrationTest(name string) func(t *testing.T) {
266262
InstanceUid: []byte("test-2"),
267263
Capabilities: uint64(protobufs.ServerCapabilities_ServerCapabilities_OffersRemoteConfig),
268264
Flags: uint64(protobufs.ServerToAgentFlags_ServerToAgentFlags_ReportFullState),
269-
ErrorResponse: &protobufs.ServerErrorResponse{
270-
ErrorMessage: "error retrieving remote configuration: agent could not be identified: service.name attribute must be provided",
271-
Type: protobufs.ServerErrorResponseType_ServerErrorResponseType_Unknown,
272-
},
273265
},
274266
},
275267
{

extension/apmconfigextension/opamp_callbacks.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,11 @@ func (rc *remoteConfigCallbacks) onMessage(ctx context.Context, conn types.Conne
155155

156156
remoteConfig, err := rc.configClient.RemoteConfig(ctx, loadedAgent.identifyingAttributes, loadedAgent.lastConfigHash)
157157
if err != nil {
158+
rc.logger.Error(fmt.Sprintf("error retrieving remote configuration: %s", err), agentUidField)
158159
// remote config client could not identify the agent
159160
if errors.Is(err, apmconfig.UnidentifiedAgent) {
160161
serverToAgent.Flags = uint64(protobufs.ServerToAgentFlags_ServerToAgentFlags_ReportFullState)
162+
return &serverToAgent
161163
}
162164
return rc.serverError(fmt.Sprintf("error retrieving remote configuration: %s", err), &serverToAgent)
163165
} else if remoteConfig == nil {

extension/apmconfigextension/opamp_callbacks_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ func TestOnMessage(t *testing.T) {
104104
InstanceUid: []byte("test"),
105105
Capabilities: uint64(protobufs.ServerCapabilities_ServerCapabilities_OffersRemoteConfig),
106106
Flags: uint64(protobufs.ServerToAgentFlags_ServerToAgentFlags_ReportFullState),
107-
ErrorResponse: &protobufs.ServerErrorResponse{
108-
ErrorMessage: "error retrieving remote configuration: agent could not be identified",
109-
Type: protobufs.ServerErrorResponseType_ServerErrorResponseType_Unknown,
110-
},
111107
},
112108
},
113109
},

0 commit comments

Comments
 (0)