Skip to content

Feature/final backup#198

Open
Abhinavpv28 wants to merge 125 commits into
developfrom
feature/final_backup
Open

Feature/final backup#198
Abhinavpv28 wants to merge 125 commits into
developfrom
feature/final_backup

Conversation

@Abhinavpv28
Copy link
Copy Markdown
Contributor

No description provided.

@Abhinavpv28
Copy link
Copy Markdown
Contributor Author

create an HLD for this PR

@Abhinavpv28
Copy link
Copy Markdown
Contributor Author

@copilot create an HLD for this PR

Agent-Logs-Url: https://github.com/rdkcentral/remote_debugger/sessions/ae2d9fe3-d174-4c46-bcc3-54e2935ca097

Co-authored-by: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 13, 2026 17:26
@Abhinavpv28 Abhinavpv28 review requested due to automatic review settings May 13, 2026 17:26
Copilot AI review requested due to automatic review settings May 13, 2026 17:27
@Abhinavpv28 Abhinavpv28 review requested due to automatic review settings May 13, 2026 17:27
Copy link
Copy Markdown

Copilot AI commented May 13, 2026

@copilot create an HLD for this PR

Created the HLD at .github/docs/IssueType_Suffix_HLD.md (commit 2555b54). The document covers:

  • Architecture overview — system context diagram showing how the suffix flows from the RBUS/RFC event through rrdEventProcessrrdJsonParserrrdRunCmdThread → upload
  • Data structures — updated data_buf struct with the new suffix field and its lifecycle
  • Key algorithmssplit_issue_type() step-by-step with examples, systemd unit-name disambiguation, and debug_outputs.txt open-mode change
  • Mermaid flowcharts — for split_issue_type, end-to-end event processing, and systemd execution
  • Sequence diagrams — nominal (suffix present) and rejection (oversized suffix) paths
  • Error handling & security — OOM, overflow, and injection prevention
  • Testing — unit-test and L2 test mapping
  • Impact analysis — per-component change summary

Copilot AI review requested due to automatic review settings May 13, 2026 17:30
@github-actions
Copy link
Copy Markdown

Code Coverage Summary

                               Total:|84.1%   6224|97.3%  1660|    -      0

Copy link
Copy Markdown
Contributor

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

Copilot reviewed 16 out of 16 changed files in this pull request and generated 9 comments.

Comments suppressed due to low confidence (2)

test/functional-tests/tests/test_rrd_static_profile_report_with_suffix.py:136

  • The variable names in the success/failure branches are swapped. SCRIPT_SUCCESS is assigned the string "Debug Information Report upload Failed" and SCRIPT_FAILURE is assigned "Debug Information Report upload Success", but the print messages below treat a match on SCRIPT_SUCCESS as "Script execution success" and a match on SCRIPT_FAILURE as "Script execution failed". This means a failed upload will be reported as a success and vice versa. Swap the string values (or swap the variable names) so the names match the log content they are checking.
    SCRIPT_SUCCESS = "Debug Information Report upload Failed"
    SCRIPT_FAILURE = "Debug Information Report upload Success"
    if SCRIPT_SUCCESS in grep_rrdlogs(SCRIPT_SUCCESS):
        print("Script execution success")
    elif SCRIPT_FAILURE in grep_rrdlogs(SCRIPT_FAILURE):
        print("Script execution failed")
    else:

test/functional-tests/tests/test_rrd_static_profile_report_with_suffix_negative_case.py:139

  • Same swap as in the positive-case file: SCRIPT_SUCCESS holds the "...upload Failed" string while SCRIPT_FAILURE holds the "...upload Success" string, but the print branches treat them as their names suggest. The reporting will be inverted. Please swap the string values or the variable names.
    SCRIPT_SUCCESS = "Debug Information Report upload Failed"
    SCRIPT_FAILURE = "Debug Information Report upload Success"
    if SCRIPT_SUCCESS in grep_rrdlogs(SCRIPT_SUCCESS):
        print("Script execution success")
    elif SCRIPT_FAILURE in grep_rrdlogs(SCRIPT_FAILURE):
        print("Script execution failed")
    else:

Comment on lines +96 to +107
SERVICE_START = f"Starting remote_debugger_{ISSUE_STRING} service success"
assert SERVICE_START in grep_rrdlogs(SERVICE_START)

JOURNAL_START = f"journalctl remote_debugger_{ISSUE_STRING} service success"
assert JOURNAL_START in grep_rrdlogs(JOURNAL_START)

SLEEP_TIME = "Sleeping with timeout"
assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME)
sleep(20)

SERVICE_STOP = f"Stopping remote_debugger_{ISSUE_STRING} service"
assert SERVICE_STOP in grep_rrdlogs(SERVICE_STOP)
Comment on lines +80 to +85
ISSUE_NODE, ISSUE_SUBNODE = ISSUE_STRING.split('.')
else:
node = ISSUE_STRING
subnode = None

ISSUE_FOUND = f"Issue Data Node: {ISSUE_NODE} and Sub-Node: {ISSUE_SUBNODE} found in Static JSON File /etc/rrd/remote_debugger.json"
on:
pull_request:
branches: [ develop ]
branches: [ develop, feature/final_backup]
Comment thread src/rrdEventProcess.c
Comment on lines +619 to +623
if (rbuf->jsonPath != NULL)
{
free(rbuf->jsonPath);
rbuf->jsonPath = NULL;
}
Comment thread src/rrdRunCmdThread.c

/* Open debug_output.txt file*/
filePointer = fopen(finalOutFile, "a+");
filePointer = fopen(finalOutFile, "w+");
Comment thread src/rrdEventProcess.c
Comment on lines +82 to +84
char base[128] = {0};
char local_suffix[128] = {0};
split_issue_type(cmdMap[index], base, sizeof(base), local_suffix, sizeof(local_suffix));
Comment thread src/rrdEventProcess.c
while (str[source] != '\0')
{
if (isalnum(str[source]) || str[source] == ',' || str[source] == '.')
if (isalnum(str[source]) || str[source] == ',' || str[source] == '.')
Copilot AI review requested due to automatic review settings May 13, 2026 17:35
@github-actions
Copy link
Copy Markdown

Code Coverage Summary

                               Total:|84.1%   6224|97.3%  1660|    -      0

1 similar comment
@github-actions
Copy link
Copy Markdown

Code Coverage Summary

                               Total:|84.1%   6224|97.3%  1660|    -      0

Copy link
Copy Markdown
Contributor

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

Copilot reviewed 16 out of 16 changed files in this pull request and generated 7 comments.

Comments suppressed due to low confidence (5)

test/functional-tests/tests/test_rrd_static_profile_report_with_suffix_negative_case.py:110

  • The expected log message hard-codes (12 > 10) but RRD_MAX_SUFFIX_LEN is defined as 9 in rrdJsonParser.c, so the actual log emitted by split_issue_type() will be Suffix after 'Device.Info' exceeds max length (12 > 9); discarding. This assertion will never match and the test will always fail. Update the literal to (12 > 9) (or compute it from the constant) so it matches the format string in src/rrdJsonParser.c.
    SUFFIX_EXCEEDS = f"Suffix after 'Device.Info' exceeds max length (12 > 10); discarding"
    assert SUFFIX_EXCEEDS in grep_rrdlogs(SUFFIX_EXCEEDS)

test/functional-tests/tests/test_rrd_static_profile_report_with_suffix.py:107

  • executeCommands() in src/rrdRunCmdThread.c now builds the systemd unit name as remote_debugger_<rfcvalue><epoch> and the start/journal/stop log lines no longer contain remote_debugger_<rfcvalue> followed by a space and service. With ISSUE_STRING = "Device.Info" the produced log is e.g. Starting remote_debugger_Device.Info1715600000 service success, while these asserts look for the substring Starting remote_debugger_Device.Info service success (and similarly for journalctl ... service success and Stopping ... service). None of these substrings will be present, so the asserts will fail. Either match the new format (e.g. anchor on remote_debugger_Device.Info as a prefix only) or use a regex that tolerates the appended epoch. The same applies to the corresponding asserts in the negative-case file (lines 96–107).
    SERVICE_START = f"Starting remote_debugger_{ISSUE_STRING} service success"
    assert SERVICE_START in grep_rrdlogs(SERVICE_START)

    JOURNAL_START = f"journalctl remote_debugger_{ISSUE_STRING} service success"
    assert JOURNAL_START in grep_rrdlogs(JOURNAL_START)

    SLEEP_TIME = "Sleeping with timeout"
    assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME)
    sleep(20)

    SERVICE_STOP = f"Stopping remote_debugger_{ISSUE_STRING} service"
    assert SERVICE_STOP in grep_rrdlogs(SERVICE_STOP)

test/functional-tests/tests/test_rrd_static_profile_report_with_suffix_negative_case.py:116

  • In the negative case the suffix is longer than RRD_MAX_SUFFIX_LEN and is therefore discarded, leaving cmdBuff->suffix as NULL. In checkIssueNodeInfo() the upload tarName is then built as "%s" from buff->mdata only (no trailing _), so the generated upload filename will be AABBCCDDEEFF_DEVICE_INFO — without the trailing underscore. These asserts expect DEVICE_INFO_ (trailing _) and will not match. Drop the trailing underscore from the expected strings, or test for the prefix only.
    GENERATE_FILE = f"Generated filename: AABBCCDDEEFF_DEVICE_INFO_"
    assert GENERATE_FILE in grep_rrdlogs(GENERATE_FILE)

    START_UPLOAD = f"Starting upload - server: mockxconf, protocol: HTTP, file: AABBCCDDEEFF_DEVICE_INFO_"
    assert START_UPLOAD in grep_rrdlogs(START_UPLOAD)

test/functional-tests/tests/test_rrd_static_profile_report_with_suffix.py:137

  • These two log lookups are inverted: SCRIPT_SUCCESS is assigned the string "Debug Information Report upload Failed" and SCRIPT_FAILURE is assigned "Debug Information Report upload Success", so the branches that print "Script execution success" and "Script execution failed" are swapped with respect to what they actually mean. Either swap the two constant values or swap the print messages to match.
    SCRIPT_SUCCESS = "Debug Information Report upload Failed"
    SCRIPT_FAILURE = "Debug Information Report upload Success"
    if SCRIPT_SUCCESS in grep_rrdlogs(SCRIPT_SUCCESS):
        print("Script execution success")
    elif SCRIPT_FAILURE in grep_rrdlogs(SCRIPT_FAILURE):
        print("Script execution failed")
    else:
        print("Script execution not found in logs")

test/functional-tests/tests/test_rrd_static_profile_report_with_suffix_negative_case.py:140

  • Same swap as in the positive-suffix test: SCRIPT_SUCCESS holds the "...Failed" string and SCRIPT_FAILURE holds the "...Success" string, so the messages printed for the two branches are inverted relative to their variable names. Please correct the assignment or the printed messages.
    SCRIPT_SUCCESS = "Debug Information Report upload Failed"
    SCRIPT_FAILURE = "Debug Information Report upload Success"
    if SCRIPT_SUCCESS in grep_rrdlogs(SCRIPT_SUCCESS):
        print("Script execution success")
    elif SCRIPT_FAILURE in grep_rrdlogs(SCRIPT_FAILURE):
        print("Script execution failed")
    else:
        print("Script execution not found in logs")

Comment on lines +96 to +106
SERVICE_START = f"Starting remote_debugger_{ISSUE_STRING} service success"
assert SERVICE_START in grep_rrdlogs(SERVICE_START)

JOURNAL_START = f"journalctl remote_debugger_{ISSUE_STRING} service success"
assert JOURNAL_START in grep_rrdlogs(JOURNAL_START)

SLEEP_TIME = "Sleeping with timeout"
assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME)
sleep(20)

SERVICE_STOP = f"Stopping remote_debugger_{ISSUE_STRING} service"
Comment on lines +80 to +83
ISSUE_NODE, ISSUE_SUBNODE = ISSUE_STRING.split('.')
else:
node = ISSUE_STRING
subnode = None
on:
pull_request:
branches: [ develop ]
branches: [ develop, feature/final_backup]
Comment thread src/rrdEventProcess.c
Comment on lines 138 to 147
if(cmdBuff)
{
if (cmdBuff->suffix)
{
free(cmdBuff->suffix);
cmdBuff->suffix = NULL;
}
free(cmdBuff);
cmdBuff = NULL;
}
And the issuetype request should match between Send and Receive
When the remotedebugger received the message from webPA event
Then remotedebugger should read the Json file
And remotedebugger logs should contain the Json File Parse Failed
Comment thread src/rrdRunCmdThread.c
Comment on lines +379 to +380
time_t epochTime = time(NULL);
snprintf(remoteDebuggerServiceStr, sizeof(remoteDebuggerServiceStr),"%s%s%ld", remoteDebuggerPrefix, cmdData->rfcvalue, (long)epochTime);
Comment thread src/rrdJsonParser.c
Comment on lines +102 to +144
const char *underscore = strchr(input, '_');
if (underscore)
{
/* Always split at the first underscore — base never contains '_' */
size_t b_len = (size_t)(underscore - input);
if (b_len >= base_len) b_len = base_len - 1;
strncpy(base, input, b_len);
base[b_len] = '\0';

/* Keep the suffix only when its total length (including '_') is
* within the allowed limit; longer tokens are discarded. */
if (strlen(underscore) <= RRD_MAX_SUFFIX_LEN)
{
/* Sanitize: retain only [A-Za-z0-9_-] to prevent injection when
* the suffix is later embedded in file names or command arguments. */
size_t si = 0, di = 0;
size_t max_copy = suffix_len - 1;
while (underscore[si] != '\0' && di < max_copy)
{
char ch = underscore[si];
if (isalnum((unsigned char)ch) || ch == '_' || ch == '-')
{
suffix[di++] = ch;
}
si++;
}
suffix[di] = '\0';
}
else
{
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Suffix after '%s' exceeds max length (%zu > %d); discarding\n",
__FUNCTION__, __LINE__, base, strlen(underscore), RRD_MAX_SUFFIX_LEN);
suffix[0] = '\0';
}
}
else
{
/* No underscore — full input is the base */
strncpy(base, input, base_len - 1);
base[base_len - 1] = '\0';
suffix[0] = '\0';
}
}
@github-actions
Copy link
Copy Markdown

Code Coverage Summary

                               Total:|84.1%   6224|97.3%  1660|    -      0

Copilot AI review requested due to automatic review settings May 13, 2026 17:44
@github-actions
Copy link
Copy Markdown

Code Coverage Summary

                               Total:|84.1%   6224|97.3%  1660|    -      0

Copy link
Copy Markdown
Contributor

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

Copilot reviewed 16 out of 16 changed files in this pull request and generated 8 comments.

Comments suppressed due to low confidence (2)

test/functional-tests/tests/test_rrd_static_profile_report_with_suffix.py:137

  • The variable names SCRIPT_SUCCESS and SCRIPT_FAILURE are assigned to strings whose meanings are inverted: SCRIPT_SUCCESS is set to the "Failed" log message, and SCRIPT_FAILURE is set to the "Success" log message. As a result, the subsequent branches print "Script execution success" when the upload actually failed (and vice versa), making the test output misleading.
    SCRIPT_SUCCESS = "Debug Information Report upload Failed"
    SCRIPT_FAILURE = "Debug Information Report upload Success"
    if SCRIPT_SUCCESS in grep_rrdlogs(SCRIPT_SUCCESS):
        print("Script execution success")
    elif SCRIPT_FAILURE in grep_rrdlogs(SCRIPT_FAILURE):
        print("Script execution failed")
    else:
        print("Script execution not found in logs")

test/functional-tests/tests/test_rrd_static_profile_report_with_suffix_negative_case.py:140

  • Same inversion as the positive-case test: SCRIPT_SUCCESS points to the "Failed" log line and SCRIPT_FAILURE points to the "Success" log line, causing the printed status to be the opposite of reality.
    SCRIPT_SUCCESS = "Debug Information Report upload Failed"
    SCRIPT_FAILURE = "Debug Information Report upload Success"
    if SCRIPT_SUCCESS in grep_rrdlogs(SCRIPT_SUCCESS):
        print("Script execution success")
    elif SCRIPT_FAILURE in grep_rrdlogs(SCRIPT_FAILURE):
        print("Script execution failed")
    else:
        print("Script execution not found in logs")

Comment on lines +82 to +85
node = ISSUE_STRING
subnode = None

ISSUE_FOUND = f"Issue Data Node: {ISSUE_NODE} and Sub-Node: {ISSUE_SUBNODE} found in Static JSON File /etc/rrd/remote_debugger.json"
on:
pull_request:
branches: [ develop ]
branches: [ develop, feature/final_backup]
Comment thread src/rrdRunCmdThread.c

/* Open debug_output.txt file*/
filePointer = fopen(finalOutFile, "a+");
filePointer = fopen(finalOutFile, "w+");
Comment thread src/rrdEventProcess.c
Comment on lines 138 to 147
if(cmdBuff)
{
if (cmdBuff->suffix)
{
free(cmdBuff->suffix);
cmdBuff->suffix = NULL;
}
free(cmdBuff);
cmdBuff = NULL;
}
Comment thread src/rrdEventProcess.c
while (str[source] != '\0')
{
if (isalnum(str[source]) || str[source] == ',' || str[source] == '.')
if (isalnum(str[source]) || str[source] == ',' || str[source] == '.')
Comment thread src/rrdEventProcess.c
Comment on lines 732 to 735
int cnt = 1, i = 0;
char *str = input_str;

removeSpecialCharacterfromIssueTypeList(str);
while (*str == delimeter)

## Document Information

| Field | Value |
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