Highlighted
Absent Member.
Absent Member.
406 views

Parsing failed: TypeError: Cannot call method "replace"


Hi,

when i troubleshooting my collector, sentinel GUI message prompt
following:


Parsing failed: TypeError: Cannot call method "replace" of undefined;
input:

my release.js is following:
----------------------------------------------------------------------
Collector.prototype.initialize = function() {
this.PARSER.getOffsetData = function(input) {
if (typeof input.RXMap != "undefined") {
return input.RXMap.REQUEST_TM;
}
};
conn.addParser(this.PARSER.getOffsetData);
return true;
};

Collector.prototype.cleanup = function() {
return true;
};


Connector.prototype.sendQuery = function() {
return true;
};


Record.prototype.preParse = function(e) {
if (this.CONNECTION_ERROR != null || typeof this.RXMap == "undefined")
{ return false; }

if (this.CONNECTION_METHOD == "DATABASE") {

for (var field in this.RXMap) {
this[field] = this.RXMap[field];
}
}

return true;
};

Record.prototype.parse = function(e) {

var detstring =
this.RXMap.REQUEST_TM.replace(/(\d+)\/(\d+)\/(\d{4})\s(\S+)/g, '$1/$2/$3
$4 GMT');
var dt = new Date(detstring);
e.ObserverEventTime(dt);
return true;
};


Record.prototype.normalize = function(e) {
instance.SEND_EVENT =true;
return true;
};

Record.prototype.postParse = function(e) {
return true;
};


Record.prototype.reply = function(e) {
return true;

----------------------------------------------------------------------------
my sqlquery.base is following:

SELECT TOP 100 * FROM TS_QUERYBILLSIGNED_LOG WHERE REQUEST_TM > %s


My table sample is following:
----------------------------------------------------------------------------------

CUSTCODE,BEGIN_TM,END_TM,PAGEINDEX,QUERYTYPE,SYSTEMNAME,SIGNEDTYPE,CLIENTIP,CLIENTMAC,CLIENTNAME,METHODNAME,REQUEST_TM,ANSWER_TM,ANSWER_TOTAL,ANSWER_CURRENTCOUNT,LOG_ID,WAYBILL_NOS
8710294837,12/30/2013,1/2/2014
23:59,0,0,CSS-CLIENT,0,221.213.26.241,6C-F0-49-CD-2C-CD,a0af75ce888346e,waybillSingedTotal,1/3/2014
14:50,1/3/2014 14:50,28,4,433676211,

-----------------------------------------------------------------------------------------
My table Schema is following:

USE [sfere]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ts_querybillsigned_log](
[CUSTCODE] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[BEGIN_TM] [datetime] NULL,
[END_TM] [datetime] NULL,
[PAGEINDEX] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[QUERYTYPE] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[SYSTEMNAME] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[SIGNEDTYPE] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CLIENTIP] [varchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CLIENTMAC] [varchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CLIENTNAME] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[METHODNAME] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[REQUEST_TM] [datetime] NULL,
[ANSWER_TM] [datetime] NULL,
[ANSWER_TOTAL] [numeric](20, 0) NULL,
[ANSWER_CURRENTCOUNT] [numeric](20, 0) NULL,
[LOG_ID] [numeric](30, 0) NOT NULL,
[WAYBILL_NOS] [varchar](400) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

Thanks
Best Regards!
Steve zeng


--
steve_zeng
------------------------------------------------------------------------
steve_zeng's Profile: https://forums.netiq.com/member.php?userid=3875
View this thread: https://forums.netiq.com/showthread.php?t=50290

0 Likes
1 Reply
Highlighted
Absent Member.
Absent Member.


steve_zeng;242145 Wrote:
> Hi,
>
> when i troubleshooting my collector, sentinel GUI message prompt
> following:
>
>
> Parsing failed: TypeError: Cannot call method "replace" of undefined;
> input:
>
> my release.js is following:
> ----------------------------------------------------------------------
> Collector.prototype.initialize = function() {
> this.PARSER.getOffsetData = function(input) {
> if (typeof input.RXMap != "undefined") {
> return input.RXMap.REQUEST_TM;
> }
> };
> conn.addParser(this.PARSER.getOffsetData);
> return true;
> };
>
> Collector.prototype.cleanup = function() {
> return true;
> };
>
>
> Connector.prototype.sendQuery = function() {
> return true;
> };
>
>
> Record.prototype.preParse = function(e) {
> if (this.CONNECTION_ERROR != null || typeof this.RXMap == "undefined")
> { return false; }
>
> if (this.CONNECTION_METHOD == "DATABASE") {
>
> for (var field in this.RXMap) {
> this[field] = this.RXMap[field];
> }
> }
>
> return true;
> };
>
> Record.prototype.parse = function(e) {
>
> var detstring =
> this.RXMap.REQUEST_TM.replace(/(\d+)\/(\d+)\/(\d{4})\s(\S+)/g, '$1/$2/$3
> $4 GMT');
> var dt = new Date(detstring);
> e.ObserverEventTime(dt);
> return true;
> };
>
>
> Record.prototype.normalize = function(e) {
> instance.SEND_EVENT =true;
> return true;
> };
>
> Record.prototype.postParse = function(e) {
> return true;
> };
>
>
> Record.prototype.reply = function(e) {
> return true;
>
> ----------------------------------------------------------------------------
> my sqlquery.base is following:
>
> SELECT TOP 100 * FROM TS_QUERYBILLSIGNED_LOG WHERE REQUEST_TM > %s
>
>
> My table sample is following:
> ----------------------------------------------------------------------------------
>
> CUSTCODE,BEGIN_TM,END_TM,PAGEINDEX,QUERYTYPE,SYSTEMNAME,SIGNEDTYPE,CLIENTIP,CLIENTMAC,CLIENTNAME,METHODNAME,REQUEST_TM,ANSWER_TM,ANSWER_TOTAL,ANSWER_CURRENTCOUNT,LOG_ID,WAYBILL_NOS
> 8710294837,12/30/2013,1/2/2014
> 23:59,0,0,CSS-CLIENT,0,221.213.26.241,6C-F0-49-CD-2C-CD,a0af75ce888346e,waybillSingedTotal,1/3/2014
> 14:50,1/3/2014 14:50,28,4,433676211,
>
> -----------------------------------------------------------------------------------------
> My table Schema is following:
>
> USE [sfere]
> GO
>
> SET ANSI_NULLS ON
> GO
> SET QUOTED_IDENTIFIER ON
> GO
> SET ANSI_PADDING ON
> GO
> CREATE TABLE [dbo].[ts_querybillsigned_log](
> [CUSTCODE] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
> [BEGIN_TM] [datetime] NULL,
> [END_TM] [datetime] NULL,
> [PAGEINDEX] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
> [QUERYTYPE] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
> [SYSTEMNAME] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
> [SIGNEDTYPE] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
> [CLIENTIP] [varchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
> [CLIENTMAC] [varchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
> [CLIENTNAME] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
> [METHODNAME] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
> [REQUEST_TM] [datetime] NULL,
> [ANSWER_TM] [datetime] NULL,
> [ANSWER_TOTAL] [numeric](20, 0) NULL,
> [ANSWER_CURRENTCOUNT] [numeric](20, 0) NULL,
> [LOG_ID] [numeric](30, 0) NOT NULL,
> [WAYBILL_NOS] [varchar](400) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> ) ON [PRIMARY]
>
> GO
> SET ANSI_PADDING OFF
>
> Thanks
> Best Regards!
> Steve zeng


It's throwing an exception because at some point, you are not checking
your string for nulls before calling replace. My guess is that
this.RXMap.REQUEST_TM is sometimes empty/null and when you call replace,
it then excepts. Always ensure that your string value is
non-null/defined before calling a function against it.


--
brandon.langley
------------------------------------------------------------------------
brandon.langley's Profile: https://forums.netiq.com/member.php?userid=350
View this thread: https://forums.netiq.com/showthread.php?t=50290

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.